Reputation: 95
I've a button which if clicked opens a alert dialog box with list of call logs. But only dialog box title is displayed on doing so.. Here is my code:
protected void showCustomDialog() {
// TODO Auto-generated method stub
// this method returns the cursor with all call logs.. i've checked the cursor and it is returning.
Cursor curLog = CallLogHelper.getAllCallLogs(getContentResolver());
// it fills the conNames arraylist with its values.
setCallLogs(curLog);
ListView listitems=new ListView(this);
MyAdapter adapter = new MyAdapter( this , R.layout.dialog_list,conNames);
//dialog_list is layout of each item of the list.
alertDialogStores = new AlertDialog.Builder(MainActivity.this)
.setView(listitems)
.setTitle("Stores")
.show();
}
Upvotes: 0
Views: 76
Reputation: 11194
You need to use below code for ur logs to be displayed :
use below code for forming string from arraylist something like this :
String msg="";
for(int i=0;i<conNames.size();i++)
{msg=msg+" "+conNames;}
alertDialogStores = new AlertDialog.Builder(MainActivity.this)
.setView(listitems)
.setTitle("Stores")
.show();
.setMessage("my logs"+msg);
Upvotes: 1
Reputation: 2016
Write
listitems.setAdapter(adapter);
after
ListView listitems=new ListView(this);
MyAdapter adapter = new MyAdapter( this , R.layout.dialog_list,conNames);
Upvotes: 1