1

我试图用列表视图填充我的弹出窗口。但不知何故我没有得到数据。请帮帮我。

我在此使用 openPopup() 函数来启动弹出窗口,并且 fillDataPopup() 用于在弹出窗口中填充数据。如果您需要更多详细信息,请告诉我

谢谢

/**
     * FUNCTION TO SHOW LIST OPTIONS ON LISTS BUTTON
     */
    public void openPopup(){
        LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);  
        View popupView = layoutInflater.inflate(R.layout.task_list_popup, null);
        final PopupWindow popupWindow = new PopupWindow(popupView,LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); 
        popupWindow.setFocusable(true);

        Button  btnDismiss = (Button) popupView.findViewById(R.id.dismissBUtton);
        btnDismiss.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                popupWindow.dismiss();
            }
        });
        fillDataPopup();
        popupWindow.showAsDropDown(listsButton, 50, -30);

    }

    public void fillDataPopup(){

        Cursor remindersCursor = mDBHelper.fetchAllReminders();          
        startManagingCursor(remindersCursor);                          

        // Create an array to specify the fields we want (only the TITLE)
        String[] from = new String[]{TasksDBAdapter.KEY_TITLE};     

        // and an array of the fields we want to bind in the view
        int[] to = new int[]{R.id.listNameTextId};                                

        // Now create a simple cursor adapter and set it to display -mapping layout with data
        SimpleCursorAdapter reminders = new SimpleCursorAdapter(this, R.layout.popup_lists_name,remindersCursor, from, to);   
        setListAdapter(reminders);
       // listNames.setAdaper(reminders);
    }
4

1 回答 1

0

这是什么类型的课?列表活动,列表片段?我不相信您可以使用这些类来填充这样的 ListView。

您需要使用popupView.findViewById()来定位您的 ListView 并将适配器直接传递给它。像这样的东西:

listNames = popupView.findViewById(R.id.xxx);

并恢复:

listNames.setAdaper(reminders);
于 2012-12-16T19:14:51.893 回答