<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon" />
</RelativeLayout><!--通过addView()动态添加Item-->
</LinearLayout>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon" />
</RelativeLayout><!--通过addView()动态添加Item-->
</LinearLayout>
解决方案 »
- android WebView加载百度地图是空白
- 关于 The connection to adb is down, and a severe error has occured解决方案
- 关于APK签名的问题,求救
- SQLite 时间比较的语句怎么写 求解释!!!
- Help,HTC G12刷机时出现can't open ROM zip包
- eclipse导入项目的问题
- sdk文档里面有,但是libory里面没有是怎么回事啊?
- NDK编译 环境找不到头文件怎么解决
- 通过智能手机外接一个usb UVC的开发板,远程监控【事成有报酬】
- 游戏多渠道打包工具原理
- android获取sd卡中的图片问题,测试都没问题就是程序有问题
- 运行虚拟机时如果有中文命名的文件或者文件夹就出错,求解答,谢谢!
View view = addview.findviewbyid(0x111);// 你要动态添加的view
layou.addview(addView);setcontentview(layout);大概就是这样了
有几个问题,首先,你的RelativeLayout布局的item是否属性都相同,如果相同,直接用ListView或GridView。如果不同,那么好吧,有几个item就布几个局吧,然后同理,你的item的item应该是不同的,再多布几个局吧,谁叫你们美工不让你用ListView。(其实简而言之,就是嵌套布局而已)至于填充的方法也贴上吧:
// context 如果在Activity里面可用this,其他情况的话,需要传个context进去。
LayoutInflater mLayoutInflater = LayoutInflater.from(context);
View view = mLayoutInflater.inflate(R.layout.xxx,null);
到这里引用XML的代码就这2行,可以用在任何可以获得context的情景中。
简写:
View view = LayoutInflater.from(context).inflate(R.layout.xxx,null);