0
我有一个视图的XML布局,表示一个ExpandableListAdapter显示的项目(对于每个列表项目而不是主要活动布局重复一次的XML)。我最初尝试了一个LinearLayout,但是这隐藏了三个小部件(一个图像按钮)的最后一个。我明白为什么这样做不起作用,但是我尝试了RelativeLayout,但文本视图不显示。相关的布局第一次连同一个截图,还附加了我的初始布局和屏幕截图底部FWIW。谢谢你的帮助。Android ExpandableListAdapter视图布局不按要求显示:-(
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="55dip"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/chkParent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:checked="false"/>
<EditText
android:id="@+id/edtParent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/chkParent"
android:textSize="17dip"
android:inputType="text"
android:hint="@string/strItem"/>
<ImageButton
android:id="@+id/btnExpand"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:layout_toLeftOf="@id/edtParent"
android:src="@drawable/dark_expand"
android:clickable="true"
android:hint="@string/strViewSubItems"
android:contentDescription="@string/strViewSubItems"
android:background="@null"/>
</RelativeLayout>
原线布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="55dip"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/chkParent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"/>
<EditText
android:id="@+id/edtParent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="17dip"
android:inputType="text"
android:hint="@string/strItem"/>
<ImageButton
android:id="@+id/btnExpand"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/dark_expand"
android:clickable="true"
android:hint="@string/strViewSubItems"
android:contentDescription="@string/strViewSubItems"
android:background="@null"/>
</LinearLayout>
Doh ...这是toLeftOf上的一个大脑放屁,当我发布它时,我再次将它放回...但是是的,编辑文本的左右两边都有固定的属性......这让我把图像按钮作为第二个元素,最后编辑,因为我猜测编译器只显示一个XML传递? – 2012-08-13 20:30:20
啊,有一种解决方法,只要在XML中引用另一个时使用'@ + id /'而不是'@ id /',并且您可以保持它的顺序。基本上,只是在第一次引用XML中的ID时使用“+”,无论您是设置ID还是仅指它。 – kcoppock 2012-08-13 20:33:52
哦,很好!很高兴知道。感谢您一如既往的帮助兄弟! :-) – 2012-08-13 21:29:38