i have list of videos user has recorded in app. when user long-clicks on video's name in listview, dialog pops give user options: play, rename, delete. play brings chooser video player play video. works should. delete brings dialog confirmation user wants delete video. works should. when rename clicked, it's supposed show alertdialog containing edittext custom view let user rename video.
here's xml custom view set renaming alertdialog:
<?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/flrename" android:layout_width="match_parent" android:layout_height="match_parent" > <edittext android:id="@+id/etrename" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/hint_rename" /> </framelayout>
in oncreate, setup custom view , alertdialog:
vrename = getlayoutinflater().inflate(r.layout.rename, null); etrename = (edittext)vrename.findviewbyid(r.id.etrename); adrename = new alertdialog.builder(context) .seticon(r.drawable.ic_launcher) .setmessage("rename video:") .setpositivebutton("rename", dioclrename) .setnegativebutton("cancel", null) .settitle(getstring(r.string.app_name)) .setview(vrename) .create();
when alertdialog shows up, has icon, title, message , buttons, not custom view.
from alertdialog documentation:
if want display more complex view, framelayout called "custom" , add view it:
framelayout fl = (framelayout) findviewbyid(android.r.id.custom); fl.addview(myview, new layoutparams(match_parent, wrap_content));
so maybe call:
framelayout fl = (framelayout) adrename.findviewbyid(android.r.id.custom); fl.addview(vrename, new layoutparams(match_parent, wrap_content));
or check if switching create()
show()
helps.