android - how add Adapter get view into another parent layout -
i using adapter show auto suggestion dropdown box flowlayout
eg.
<flowlayout> <textview1> <textview2> <textview3> </flowlayout>
but out put using adapter looks like
<flowlayout> <textview1> </flowlayout> <flowlayout> <textview2> </flowlayout> <flowlayout> <textview3> </flowlayout>
how can solve
my code below: java:
public class tagfilteradapter extends baseadapter implements filterable { private static final int max_results = 10; private context mcontext; private jsonarray tags; private float scale; private arraylist<pair<integer,string>> resultlist = new arraylist<pair<integer, string>>(); public tagfilteradapter(context context) { mcontext = context; } @override public int getcount() { return resultlist.size(); } @override public string getitem(int index) { // return resultlist.get(index); return null; } @override public long getitemid(int position) { return position; } @override public view getview(int position, view convertview, viewgroup parent) { if (convertview == null) { layoutinflater inflater = (layoutinflater) mcontext .getsystemservice(context.layout_inflater_service); convertview = inflater.inflate(r.layout.tag_autosuggest_dropdown, parent, false); } scale = mcontext.getresources().getdisplaymetrics().density; pair<integer, string> tagdata = resultlist.get(position); checkedtextview t = (checkedtextview) convertview.findviewbyid(r.id.checklistnew); t.settext(tagdata.second); t.settextcolor(contextcompat.getcolor(mcontext,r.color.textdark)); t.setbackgroundresource(r.drawable.selectable); t.setchecked(false); t.setclickable(true); t.setfocusable(true); int padding = (int)(10 * scale + 0.5f); t.setpadding(padding,padding,padding,padding); return convertview; }
tag_autosuggest_dropdown.xml:
<?xml version="1.0" encoding="utf-8"?> <com.nex3z.flowlayout.flowlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/tagsgroup1" android:layout_height="wrap_content" android:layout_width="match_parent" android:paddingbottom="20dp" app:childspacing="8dp" app:childspacingforlastrow="align" app:rowspacing="8dp"> <checkedtextview android:id="@+id/checklistnew" android:layout_width="wrap_content" android:layout_height="wrap_content"></checkedtextview> </com.nex3z.flowlayout.flowlayout>
it looks post code; please add more details. looks post code; please add more details.
what inflate in adapter ==> make version of design (translate layout -tag_autosuggest_dropdown- object) contain flowlayout repeat each item solution ==> flowlayout in main layout , item inflating (checkedtextview) in tag_autosuggest_dropdown :)
Comments
Post a Comment