开发者

android R.layout concept

can I genrate java code instead using xml code ? lets say i want to do this xml code in a loop :

<TableRow 
 android:id="@+id/LivingCreture"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">
 <TextView android:text="LivingCreture" 
 android:gravity="left"
 android:id="@+id/LivingCretureT"
 android:layout_width="45dp"
 android:layout_height="45dp"></TextView>
 <EditText android:text=" "
 android:gravity="center"
 android:id="@+id/LivingCretureE" 
 android:layout_width="45dp"
 android:layout_height="45dp"></EditText>
<ImageView android:id="@+id/ImageView03" android:layout_width="wrap_content"android:layout_height开发者_开发问答="wrap_content"></ImageView>       

is it possiable ?


I believe your best option is to create a "template" tag (containing all elements you want to add in the loop) and include these elements using the <include> tag as many times you need.

Have a look at

  • Android Layout Trick #2: Include to Reuse and
  • Simple example of and usage in Android XML-layouts.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜