如何覆盖android.R.layout.simple_list_item_multiple_choice的风格? [英] How to override the style of android.R.layout.simple_list_item_multiple_choice?

查看:436
本文介绍了如何覆盖android.R.layout.simple_list_item_multiple_choice的风格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用适配器=新SimpleCursorAdapter(这一点,android.R.layout.simple_list_item_multiple_choice,CUR,COLS,意见)创建一个选择题控制, 但我并不满足于选择题控制的TextView的风格,所以我必须使用以下code创建一个多选一个新的控制布局。 它工作得很好,但我不认为这是一个很好的方式,有没有什么好的code?谢谢!

适配器=新SimpleCursorAdapter(这一点,                  R.layout.mysimple_list_item_multiple_choice,                  CUR,COLS,意见);

  lv.setAdapter(适配器);
lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
 

mysimple_list_item_multiple_choice.xml

 < CheckedTextView的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@机器人:ID / text1中
    机器人:layout_width =match_parent
    机器人:layout_height =机器人:ATTR /列表preferredItemHeight
    机器人:textAppearance =机器人:ATTR / textAppearanceMedium
    机器人:重力=center_vertical
    机器人:对号=机器人:ATTR / listChoiceIndicatorMultiple
    机器人:以下属性来=6dip
    机器人:paddingRight =6dip
    机器人:ellipsize =结束
    机器人:单线=真

/>
 

解决方案

简单。

使用<包括>

创建一个新的XML布局。

 <包括机器人:ID =@ +安卓ID / simple_list_item_multiple_choice
     机器人:layout_width =match_parent
     机器人:layout_height =match_parent
     布局=@布局/标题/>
 

通过在标签中指定它们所包含的布局的根视图的:(布局_ * 属性任何安卓)

您可以覆盖所有的布局参数。

I use adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_multiple_choice, cur, cols, views) to create a multiple choice control, but I'm not satisfied of the style of the textview in the multiple choice control, so I have to use the following code to create a new layout of a multiple choice control. It works well, but I don't think it's a good way, is there any good code? Thanks!

adapter = new SimpleCursorAdapter(this, R.layout.mysimple_list_item_multiple_choice, cur, cols, views);

lv.setAdapter(adapter);
lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

mysimple_list_item_multiple_choice.xml

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:gravity="center_vertical"
    android:checkMark="?android:attr/listChoiceIndicatorMultiple"
    android:paddingLeft="6dip"
    android:paddingRight="6dip"
    android:ellipsize="end"
    android:singleLine="true"

/>

解决方案

Simple.

Use <include>.

Create a new XML layout.

     <include android:id="@+android:id/simple_list_item_multiple_choice"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     layout="@layout/title"/>

You can override all the layout parameters (any android:layout_* attributes) of the included layout's root view by specifying them in the tag.

这篇关于如何覆盖android.R.layout.simple_list_item_multiple_choice的风格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆