在内部线性布局中添加多个文本视图<;android.support.v7.widget.cardwiew>;

在内部线性布局中添加多个文本视图<;android.support.v7.widget.cardwiew>;,android,android-linearlayout,android-recyclerview,android-cardview,Android,Android Linearlayout,Android Recyclerview,Android Cardview,我想在卡片视图中的一行(水平)显示多个文本视图(每个卡片的视图数量是动态的,从服务器获取)。为此,我在卡片视图中使用线性布局,如 <LinearLayout android:id="@+id/llReader" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp"

我想在卡片视图中的一行(水平)显示多个文本视图(每个卡片的视图数量是动态的,从服务器获取)。为此,我在卡片视图中使用线性布局,如

 <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>

在适配器内部(我使用recyclerview适配器),在onBindViewHolder方法中填充时,我这样做

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

for(i=0;i如果只有TextView的原始代码正常工作,则可以将TextView与一起使用

那么你就根本不需要ImageView了。只需将
android:drawableLeft=“@drawable/yourImage”
(或
textView.SetCompoundDrawableSwithintInInsicBounds(yourImage,null,null,null)
添加到你的textView即可


对于您当前的实现,如果不查看您的代码,就无法了解如何动态添加TextView。

如果只有TextView的原始代码正常工作,您可以将TextView与一起使用

那么你就根本不需要ImageView了。只需将
android:drawableLeft=“@drawable/yourImage”
(或
textView.SetCompoundDrawableSwithintInInsicBounds(yourImage,null,null,null)
添加到你的textView即可

对于您当前的实现,如果不查看代码,就无法了解如何动态添加TextView