Hi i am working the first time with dialogs. i want to create a dialog after an item in a listView was clicked:
String[] listItems = {\"Colour\", \"Font Size
Call this method in your onItemClick method :
public void showMyCustomDialog(Context context, String title, String message)
{
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
//tell the Dialog to use the customalertdialog.xml as it's layout description
dialog.setContentView(R.layout.customalertdialog);
TextView titleText = (TextView) dialog.findViewById(R.id.txtTitleAlertDialog);
titleText.setText(title);
TextView txt = (TextView) dialog.findViewById(R.id.txtAlertDialog);
txt.setText(message);
Button dialogButton = (Button) dialog.findViewById(R.id.buttonAlertDialogCancel);
dialogButton.setText("OK");
dialogButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
Something like below :
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView> parent, View
view, int position, long id)
{
String[] listItems = {"Colour", "Font Size",};
if(listItems[position].equals("Font Size"))
{
public dialog onCreateDialog(Bundle savedInstanceState)
{
showMyCustomDialog(Context context, String title, String message) // pass title, message and activity context in this method.
}
}
}
});
Hope it will help.