autocompletetextview - How to add autocompletetext in textinputlayout programatically in android -
i created layout in main activity , trying call method need add view in main layout. not behaving same way textinputlayout
behaves.
please check code , let me know should change.
public static view gettypeaheadview(context context) { relativelayout layout = new relativelayout(context); try { relativelayout.layoutparams lp1 = new relativelayout.layoutparams( relativelayout.layoutparams.wrap_content, relativelayout.layoutparams.wrap_content); layout.setlayoutparams(lp1); linearlayout.layoutparams lp = new linearlayout.layoutparams(linearlayout.layoutparams.wrap_content, linearlayout.layoutparams.wrap_content); lp.setmargins(0, 5, 0, 0); textinputlayout textinputlayout = new textinputlayout(context); autocompletetextview autocompletetextview = new autocompletetextview(context); autocompletetextview.setheight(r.dimen.dim_40); autocompletetextview.setwidth(linearlayoutcompat.layoutparams.match_parent); autocompletetextview.settextsize(r.dimen.dim_20_sp); autocompletetextview.setlines(1); autocompletetextview.setdropdownheight(r.dimen.dim_200); autocompletetextview.setkeylistener(digitskeylistener.getinstance("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz,")); autocompletetextview.setpadding(10, 0, 0, 0); autocompletetextview.setsingleline(true); autocompletetextview.setlayoutparams(lp); textinputlayout.addview(autocompletetextview); layout.addview(textinputlayout); } catch (exception e) { e.printstacktrace(); } /*parent.addview(text); parent.addview(edittext);*/ return layout; }
i'm not entirely perhaps try defining layout parameters textinputlayout adding programmatically.
Comments
Post a Comment