I am trying to populate my pop up window with a list view.But somehow I am not getting data.
Please help me out.
I am hereby using openPopup() function to start the pop up window and fillDataPopup() is being used to populate data in pop up. Please let me know if you need any further details
Thanks
/**
* 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);
}
What type of class is this? ListActivity, ListFragment? I don’t believe you can use these classes to populate a ListView like this.
You need to use
popupView.findViewById()to locate your ListView and the pass the adapter to this directly. Something like this:and restore: