android - EditText input type not changing -


i showing dialog edit text , set input type decimal

**final edittext input = new edittext(context);  input.setinputtype(inputtype.type_number_flag_decimal);** 

it's input type working fine if using default alert.setpositivebutton , setnegativebutton click listeners. when used

dialog.getbutton(alertdialog.button_positive).setonclicklistener(new view.onclicklistener() { }

then it's input not working. below code complete code

package com.dialogs;   public class getsalestaxpopup {     context context;     private alertdialog dialog;     public void getsalestax(context context2){         this.context = context2;         alertdialog.builder alert = new alertdialog.builder(context);          alert.settitle("sales tax");         alert.setmessage("enter tax");          // set edittext view user input          final edittext input = new edittext(context);         input.setinputtype(inputtype.type_number_flag_decimal);         alert.setview(input);         alert.setpositivebutton("ok", new dialoginterface.onclicklistener() {             public void onclick(dialoginterface dialog, int whichbutton) {              }         });         alert.setnegativebutton("cancel", new dialoginterface.onclicklistener() {             public void onclick(dialoginterface dialog, int whichbutton) {              }         });         dialog = alert.create();         dialog.show();         dialog.getbutton(alertdialog.button_positive).setonclicklistener(new view.onclicklistener() {              @override             public void onclick(view v) {                 string salestax = input.gettext().tostring();                 if(!salestax.equals("")){                     toast.maketext(context, salestax, toast.length_short).show();                         }                 else{                     toast.maketext(context, "enter sales tax", toast.length_short).show();                 }             }         });         dialog.getbutton(alertdialog.button_negative).setonclicklistener(new view.onclicklistener() {              @override             public void onclick(view v) {                 if (!mypreferences.getmypreference("getsalestax", context).equals("")){                     dialog.dismiss();                 }                 else                     toast.maketext(context, "enter sales tax first", toast.length_short).show();             }         });       //  alert.show();     } } 

please guide me doing wrong. appreciated.

you need both input type class , decimal flag:

input.setinputtype(inputtype.type_class_number | inputtype.type_number_flag_decimal); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -