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

解决方案 »

  1.   

    <!--通过addView()动态添加Item--> 别忘了设置Layout各个的属性。
      

  2.   

    我想问下怎么在代码中使用定义的item xml???
      

  3.   

    Layout layout = findviewbyid(0x222);// 你的那个空的layoutLayout addView = LayoutInflate.from(this).inflate(0x123, null);// 动态添加的布局
    View view = addview.findviewbyid(0x111);// 你要动态添加的view
    layou.addview(addView);setcontentview(layout);大概就是这样了
      

  4.   

    看你的描述,给你几点建议吧,首先用LinearLayout去布局你的item,然后用你说的TextView和ImageView去填充这个item。
    有几个问题,首先,你的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);