2011-05-16 87 views
1

enter image description here大家好,我 是个新手,Android和显示使用线性布局,不知道项目有问题,如果有人能帮助我。项目列表和图片显示正常,但显示每个项目的文本框和搜索按钮,而不是显示一次。我的代码如下所示:Android的线性布局问题

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1"> 
     <ImageView 
      android:id="@+id/icon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/icon"/> 
     <TextView 
      android:id="@+id/selection" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="16sp" 
      android:textStyle="bold" /> 
     </LinearLayout> 
     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1"> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/searchHeader"/> 
     <EditText 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/searchItem"/> 
     <Button 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/search" 
      android:onClick="Search"/> 
     </LinearLayout> 
</LinearLayout> 
+1

你应该回去先接受回答前面的问题。 – 2011-05-16 18:01:14

回答

0

尝试移动TextView的,他们是在linearlayouts外搜索按钮

+0

您好,感谢您的回复,你的意思是完全移动的线性布局外TextView的和按钮或只是里面一个? – user676567 2011-05-16 18:16:46

+0

在里面的那个(里面有三个),哈哈。 – Amplify91 2011-05-16 18:20:19

+0

你究竟想要完成什么?也许你可以发布你想要布局的模型图像。 – Amplify91 2011-05-16 18:22:02

3

有了这个XML,你应该只看到了一个ImageView的,而不是图像的列表,你discribed。 。你是否以编程方式改变这种布局,以便显示各种图像?也许你还会再次添加你只想要一次的物品。

+0

嗨,不,我现在只显示一个图像,因为我还没有想出如何将图像动态链接到我的XML文件中的文本。 – user676567 2011-05-16 18:14:29

+1

你不能在静态XML中做动态的事情。但是您可以使用列表显示小部件并使用适当的适配器来动态加载其内容。 – Hyperboreus 2011-05-16 18:18:14