no

How to display a listview inside alert dialog in android

Android Studio - Displaying List View Inside AlertDialog 1.) Follow this code: ================ >Note: custom_dialog_layout.xml is...

Android Studio - Displaying List View Inside AlertDialog


1.) Follow this code:
================
>Note: custom_dialog_layout.xml is the layout that will pop-up
>Note: row.xml is the item used for populating row
AlertDialog.Builder  builder = new AlertDialog.Builder(new ContextThemeWrapper(MainActivity.this, android.R.style.Theme_Holo));

builder.setTitle("Custom Dialog");

View customView = LayoutInflater.from(MainActivity.this).inflate(R.layout.custom_dialog_layout, null, false);

ListView listList1 = (ListView)customView.findViewById(R.id.listView1);
String[] stringArray1 = new String[] { "Bright Mode", "Normal Mode" };
ArrayAdapter adapter1 = new MyListAdapter(MainActivity.this, R.layout.row, stringArray1);
listList1.setAdapter(adapter1);

builder.setView(customView);

builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
       //Ok

    }
});

builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
        //Cancel
    }
});

builder.show();

Related

java-android 3008929340804856622

Post a Comment Default Comments

item