Add Edittext Inside Dialog Box
If you haven`t yet watched the video...Watch it right now!!!
The code used in the above video is available here.
final EditText edittext1= new EditText(MainActivity.this);
LinearLayout.LayoutParams lpar = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
edittext1.setLayoutParams(lpar);
dialog.setView(edittext1);
textview1.setText(edittext1.getText());
It shows error... For line :
ReplyDeletedialog.setView(edittext1);
And the erorrs says that dialog cannot be resolved.
Type the correct name
DeleteThis happens because you forgot to create a dialog component Whit the same name of the one called in code as above!
DeleteOne more thing you should remember is that you should create a textview and me it as the one is going to receive the parameter
DeleteYou should create a dialogue companent named 'dialog' to work this code.
DeleteChange dilog name with your dialog name
ReplyDeleteLike
dialog1.setView
how to sav it in variable
ReplyDeleteHow to do that when you enter one text was displayed another?
ReplyDeletePlease I want to add two edit text in the dialog in sketchware
ReplyDeleteUse (new) LinearLayout instead, create 2 (new) EditText then use AddChild.
DeleteUse .toString() like edittext1.getText().toString();
ReplyDelete