试试这个:
String[] p_values = populate_the_list_with_your_content();
ListView mListview = new ListView(this); // pass your context here
adpter = new ArrayAdapter<String>(this,R.layout.your_raw_item_with_whatever_you_like, p_values);
mListview.setAdapter(adpter);
AlertDialog mAlertDialog;
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
AlertDialog.Builder mBuider = new AlertDialog.Builder(your_context);
mBuider.setTitle("title"); // optional
mBuider.setPositiveButton("positive", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// do what you got to do - just be positive
}
});
mBuider.setNegativeButton("Back",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// negative reaction
}
});
mBuider.setView(mListview);
mAlertDialog = mBuider.create();
lp.copyFrom(mAlertDialog.getWindow().getAttributes());
mAlertDialog.show();
为我工作。开心!