5

tablerow-sを使用して、スクロールビューにテーブルレイアウトをプログラムで設定しています。テーブル行では、データをテキストビューに入れています。
今私の質問は、プログラムで(Javaで)次のようにテキストビューを設定する方法です:

<TextView
    android:layout_width="20dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="10dp"
/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    style="@style/tab"
    android:layout_weight="0.4"
    android:minWidth="80dp"
/>

<TextView
    android:layout_width="81dp"
    android:layout_height="wrap_content"
    style="@style/tab"
/>

<TextView
    android:layout_width="70dp"
    android:layout_height="wrap_content"
    style="@style/tab"
/>

<TextView
    android:layout_width="50dp"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:gravity="center"
    style="@style/tab"
    android:textStyle="bold"
    android:textColor="@color/black"
    android:layout_marginRight="5dp"
/>
4

2 に答える 2

1

これを試してみてください、それは役立つかもしれません

    TextView view = new TextView(this);
    view.setText("example textview ");
   //adding layout properties 
    view.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
   // add the textview to the parentLayout
    parentLayout.addView(view);

関連リンク : textView を linearLayout に動的に追加する

Androidで動的テキストビューを生成するには?

TextView を動的に追加する - Android

于 2013-07-01T10:21:34.017 に答える