Input text dialog Android -


when user clicks button in app (which printed in surfaceview), i'd text dialog appear , store result in string. i'd text dialog overlay current screen. how can this?

thanks in advance.

sounds opportunity use alertdialog.

as basic seems, android not have built-in dialog (as far know). fortunately, it's little work on top of creating standard alertdialog. need create edittext user input data, , set view of alertdialog. can customize type of input allowed using setinputtype, if need.

if you're able use member variable, can set variable value of edittext, , persist after dialog has dismissed. if can't use member variable, may need use listener send string value right place. (i can edit , elaborate more if need).

within class:

private string m_text = ""; 

within onclicklistener of button (or in function called there):

alertdialog.builder builder = new alertdialog.builder(this); builder.settitle("title");  // set input final edittext input = new edittext(this); // specify type of input expected; this, example, sets input password, , mask text input.setinputtype(inputtype.type_class_text | inputtype.type_text_variation_password); builder.setview(input);  // set buttons builder.setpositivebutton("ok", new dialoginterface.onclicklistener() {      @override     public void onclick(dialoginterface dialog, int which) {         m_text = input.gettext().tostring();     } }); builder.setnegativebutton("cancel", new dialoginterface.onclicklistener() {     @override     public void onclick(dialoginterface dialog, int which) {         dialog.cancel();     } });  builder.show(); 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -