Adding multiple textviews in Linear Layout inside <android.support.v7.widget.CardView> -


i want show multiple text views in 1 line (horizontally) inside card view (number of views dynamic each card, fetched server). i'm using linear layout in card view like,

 <linearlayout         android:id="@+id/llreader"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_margintop="10dp"         android:layout_marginleft="10dp"         android:orientation="horizontal" >     </linearlayout> 

and inside adapter(i using recyclerview adapter) while populating in onbindviewholder method i'm doing this,

for (i=0;i<array.size();i++){ // arraysize different each card   //create new texview   // set text of textview accordingly   // add linear layout (ll.addview(tv) } 

then prepare apk , test it. cards getting populated correctly. far good.

but after few time, when cards populated, noticed linear layouts merged , cards having linear layout of other cards. can reason , how solve it?

p.s. tried having single text view instead of linear layout , keep on adding text string inside loop , call settext method of text view. working fine i.e., showing details related particular card only. can't use same each text view having image well, new text views (image + sometext). please suggest me if there other way of doing using linear layout.

if original code textviews working, can use textview compound drawables.

then wouldn't need imageview @ all. add android:drawableleft="@drawable/yourimage" (or textview. setcompounddrawableswithintrinsicbounds(yourimage, null, null, null) adding dynamically) textview.

as current implementation, it's not possible without looking @ code how dynamically adding textview.


Comments