【问题标题】:Custom view where i can use linearlayer few times我可以多次使用线性层的自定义视图
【发布时间】:2013-07-30 14:12:01
【问题描述】:

我有线性图层,有两个文本视图和复选框。我想创建自定义视图,并添加此代码几次。我尝试了 2 天,创建自定义视图,但我没有找到更复杂示例的示例。只有一个文本视图,或其他简单的东西。

我的线性图层:

<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 的文本,改变 id 层并添加 onclicklistener,给他。

【问题讨论】:

  • 您为什么不直接使用RelativeLayout 并将您的控件移动到您想要在布局上的任何位置?还是您特别需要嵌套布局?
  • 这段代码,是带有复选框的列表视图。但我使用 sherlockfragment,我不能使用偏好。我想要几个设置,带有复选框。而且我不想在正常布局中添加它。我想要自动这个。你能帮帮我吗?
  • 如果你需要一个带有复选框的列表视图,你应该看看这个link

标签: android android-linearlayout android-custom-view


【解决方案1】:

我使用 listview 和适配器,它工作得很好。感谢您的帮助

我使用http://javatechig.com/android/android-listview-tutorial/,并修改为我自己的程序。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-30
    • 1970-01-01
    • 1970-01-01
    • 2011-10-14
    • 2023-03-18
    • 2021-11-29
    • 1970-01-01
    相关资源
    最近更新 更多