I have an application where I would want to display a custom list view consisting of two textViews inside a custom dialog box in android. So far, I\'m having a difficult tim
Are you doing the following? You will need to inflate the layout file dialog_main
, find the ListView
, set an adapter and an OnItemClickListener for it. After this, you can use the dialog's setContentView(View)
method to get the list to display.
private void showDialog(){
final Dialog dialog = new Dialog(this);
View view = getLayoutInflater().inflate(R.layout.dialog_main, null);
ListView lv = (ListView) view.findViewById(R.id.custom_list);
// Change MyActivity.this and myListOfItems to your own values
CustomListAdapterDialog clad = new CustomListAdapterDialog(MyActivity.this, myListOfItems);
lv.setAdapter(clad);
lv.setOnItemClickListener(........);
dialog.setContentView(view);
dialog.show();
}
By the way, your adapter looks alright. It isn't working because you're not giving it anything to work on.