2012-12-16 50 views
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); 
    } 

回答

0

什么类型的类这是什么? ListActivity,ListFragment?我不相信你可以使用这些类来填充这样的ListView。

您需要使用popupView.findViewById()来找到您的ListView并将适配器直接传递给它。事情是这样的:

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

和恢复:

listNames.setAdaper(reminders); 
+0

我的类扩展listActivity像 公共类TaskManagerActivity扩展ListActivity – RayKaushik

+0

ü什么建议修改应我做..?请详细说明,因为我是新来android.Thanks – RayKaushik

+0

ListActivity不会自动查找'task_list_popup.xml'内的ListView。您必须使用上述两个步骤。 – Sam