如何覆盖android.R.layout.simple_list_item_multiple_choice的风格? [英] How to override the style of 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:机器人=http://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); mysimple_list_item_multiple_choice.xml
Use Create a new XML layout. You can override all the layout parameters (any 这篇关于如何覆盖android.R.layout.simple_list_item_multiple_choice的风格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!安卓)
lv.setAdapter(adapter);
lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
<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.
<include>
. <include android:id="@+android:id/simple_list_item_multiple_choice"
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/title"/>
android:layout_*
attributes) of the included layout's root view by specifying them in the tag.