I would like to add a single choice list to custom dialog I have tried it in different types but I am getting the app crashed with a null pointer error only.I find it can be done only in AlertDialog.Builder format only in many examples.Kindly help me on this with a example.Thanks.
Try this
String x_id;
final String[] arrayOfStrings = first.toArray(new String[first.size()]);
Dialog dialog = new Dialog(Conf_game.this);
dialog.setContentView(R.layout.dialogs);
dialog.setTitle("SELECT Item ");
final ListView lst = (ListView) dialog.findViewById(R.id.dialog_list);
lst.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_checked, android.R.id.text1,
arrayOfStrings));
lst.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int item, long arg3) {
coursetext.setText(arrayOfStrings[item]);
x_id = arrayOfStrings [item];
System.out.println(" Value of ID OF ABC OF"
+ arrayOfStrings[item] + " IS " + C_id);
dialog.dismiss();
}
});
dialog.show();