/*** (get Input)*/ Private voidShowinputdialog () {ScrollView ScrollView=Getinitview (); FinalLinearLayout layout =(LinearLayout) Scrollview.findviewbyid (30); NewAlertdialog.builder ( This). Settitle ("Please enter"). SetIcon (Android. R.drawable.ic_dialog_info). Setview (ScrollView). Setpositivebutton ("OK",NewDialoginterface.onclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) {setnewmodule (layout); }}). Setnegativebutton ("Cancel",NewDialoginterface.onclicklistener () {@Override Public voidOnClick (Dialoginterface Dialog,intwhich) { // do nothing}}). Show (); } /*** (Dynamic setting view)*/ PrivateScrollView Getinitview () {//Create a new layoutLinearLayout layout =NewLinearLayout ( This); Linearlayout.layoutparams Layoutparams=Newlinearlayout.layoutparams (ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); //set to Portrait layoutlayout.setorientation (linearlayout.vertical); //Set Layout sizeLayout.setlayoutparams (Layoutparams); //Set Layout IdLayout.setid (30); //New edit BoxEditText Titleedittext =NewEditText ( This); Titleedittext.setid (20); Titleedittext.sethint ("Please enter title:"); To add more dialog boxes, you can add them as examples.//Add the edit box to layoutLayout.addview (Titleedittext); //a scrollable ScrollView to the layout packageScrollView ScrollView =NewScrollView ( This) ; Scrollview.setlayoutparams (Layoutparams); Scrollview.addview (layout); returnScrollView; } /*** (Set the value of module) *@paramLayout*/ Private voidsetnewmodule (linearlayout layout) {String title=(EditText) Layout.findviewbyid (()). GetText (). toString (); Some code is omitted here//Set up moduleModule module =NewModule (); Module.title=title; }
Roughly as follows:
Android Dynamic Build dialog box and EditText