0
我有线性层,有两个textview和checkkbox。我想创建自定义视图,并添加这个代码几次。我尝试2天,创建自定义视图,但我没有找到更复杂的示例示例。只有一个textview或其他简单的东西。自定义视图,我可以使用线性层几次
我linearlayer:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:background="@drawable/border1px"
android:focusable="true"
android:clickable="true"
android:id="@+id/linearxyz"
>
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_marginLeft="15dip"
android:focusable="false"
android:clickable="false"
>
<TextView android:id="@+android:id/title"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Testxyz"
android:textColor="#FF0000"
/>
<TextView android:id="@+android:id/summary"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Testxyz2"
/>
</RelativeLayout>
<CheckBox
android:id="@+android:id/checkboxxyz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
我想,用这个层,我想改变的TextView,更改标识层的文本,并添加onclicklistener,给他。
为什么不直接使用'RelativeLayout'并将您的控件移动到布局的任何位置?还是你特别需要嵌套布局? –
此代码与复选框一起显示。但我使用sherlockfragment,我不能使用偏好。我想要几个设置,并带有复选框。我不想在正常的布局中添加这个。我想自动这个。你可以帮我吗? – chiken
那么如果你需要一个有复选框的listview,你应该看看这个[link](http://stackoverflow.com/questions/1505751/android-binding-data-from-a-database-to-a-checkbox-in -a-列表视图) –