android - Add TextInputLayout programmatically -


how go adding textinputlayout programmatically ?

i have tried doing,

    private edittext _edittext;     private textinputlayout _textinputlayout;      // create edittext     if (_edittext == null) {         _edittext = new edittext(this.getcontext());         _edittext.setinputtype(                 _ispassword ? inputtype.type_text_variation_password : inputtype.type_text_flag_auto_correct         );         _edittext.setlayoutparams(                 new layoutparams(0, layoutparams.match_parent)         );          if (_hint != null) {             _edittext.sethint(string.format("%s%s", hint_prefix, _hint.tolowercase()));         }          _textinputlayout = new textinputlayout(this.getcontext());         _textinputlayout.setlayoutparams(                 new layoutparams(0, layoutparams.wrap_content, edit_text_weight)         );         _textinputlayout.addview(_edittext);          this.addview(_textinputlayout);     } 

however, when compile , run following error. doing wrong here ?

10-03 21:22:16.154 2488-2488/? e/androidruntime:  caused by: java.lang.arrayindexoutofboundsexception: length=54; index=108 10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.content.res.typedarray.getvalueat(typedarray.java:1132) 10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.content.res.typedarray.getcolor(typedarray.java:446) 10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.support.design.widget.collapsingtexthelper.setcollapsedtextappearance(collapsingtexthelper.java:191) 10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.support.design.widget.textinputlayout.sethinttextappearance(textinputlayout.java:270) 10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.support.design.widget.textinputlayout.<init>(textinputlayout.java:111) 10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.support.design.widget.textinputlayout.<init>(textinputlayout.java:82) 10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.support.design.widget.textinputlayout.<init>(textinputlayout.java:78) 10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ com.syncopatesystems.splogle.iconfloatedittext.iconfloatedittext.initialize(iconfloatedittext.java:145) 10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ com.nixgadgets.iconfloatedittext.iconfloatedittext.<init>(iconfloatedittext.java:75) 10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ com.nixgadgets.iconfloatedittext.iconfloatedittext.<init>(iconfloatedittext.java:62) 10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ java.lang.reflect.constructor.newinstance(native method)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.view.layoutinflater.createview(layoutinflater.java:619)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:764)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.view.layoutinflater.rinflate(layoutinflater.java:835)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.view.layoutinflater.rinflatechildren(layoutinflater.java:798)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.view.layoutinflater.rinflate(layoutinflater.java:838)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.view.layoutinflater.rinflatechildren(layoutinflater.java:798)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.view.layoutinflater.rinflate(layoutinflater.java:838)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.view.layoutinflater.rinflatechildren(layoutinflater.java:798)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.view.layoutinflater.inflate(layoutinflater.java:515)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.view.layoutinflater.inflate(layoutinflater.java:423)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.view.layoutinflater.inflate(layoutinflater.java:374)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ com.android.internal.policy.phonewindow.setcontentview(phonewindow.java:393)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.app.activity.setcontentview(activity.java:2166)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ com.syncopatesystems.splogle.activities.signupwithemailactivity.oncreate(signupwithemailactivity.java:43)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.app.activity.performcreate(activity.java:6237)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1107)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.app.activitythread.performlaunchactivity(activitythread.java:2369)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2476)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.app.activitythread.-wrap11(activitythread.java)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.app.activitythread$h.handlemessage(activitythread.java:1344)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.os.handler.dispatchmessage(handler.java:102)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.os.looper.loop(looper.java:148)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ android.app.activitythread.main(activitythread.java:5417)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ java.lang.reflect.method.invoke(native method)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726)  10-03 21:22:16.154 2488-2488/? e/androidruntime:     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616)  

import android.app.activity; import android.os.bundle; import android.view.view; import android.widget.edittext; import android.widget.relativelayout;  public class textclass extends activity {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         // realtivelayout         // first create relativelayout hold         // textinputlayout         relativelayout relativelayout;         relativelayout = new relativelayout(this);         // set generated id         relativelayout.setid(view.generateviewid());         // define relativelayout layoutparams         relativelayout.layoutparams relativelayoutparams = new relativelayout.layoutparams(                 relativelayout.layoutparams.match_parent, relativelayout.layoutparams.match_parent);         // set layoutparams relativelayout         relativelayout.setlayoutparams(relativelayoutparams);          // edittext         // instantiate edittext view held inside of         // textinputlayout         edittext edittext = new edittext(this);         // add id         edittext.setid(view.generateviewid());         // hint text edittext field presented         // user in textinputlayout         edittext.sethint(field.gethint());         // set color of hint text inside edittext field         edittext.sethinttextcolor(getresources().getcolor(android.r.color.white));         // set font size of text user enter         edittext.settextsize(16);         // set color of text inside edittext field         edittext.settextcolor(getresources().getcolor(android.r.color.white));         // define layout params edittext field         relativelayout.layoutparams edittextparams = new relativelayout.layoutparams(                 relativelayout.layoutparams.match_parent, relativelayout.layoutparams.wrap_content);         // set edittext layout parameters edittext field         edittext.setlayoutparams(edittextparams);          /*          * next, same thing textinputlayout (instantiate,          * generate , set id, set layoutparams, set layoutparamt          * textinputlayout          */          // textinputlayout         textinputlayout textinputlayout = new textinputlayout(this);         textinputlayout.setid(view.generateviewid());         relativelayout.layoutparams textinputlayoutparams = new relativelayout.layoutparams(                 relativelayout.layoutparams.match_parent, relativelayout.layoutparams.wrap_content);         textinputlayout.setlayoutparams(textinputlayoutparams);          // add edittext textinputlayout         textinputlayout.addview(edittext, edittextparams);          // lastly, add textinputlayout (or onto) layout you've         // chosen.         relativelayout.addview(textinputlayout, textinputlayoutparams);         setcontentview(relativelayout);     }  } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -