2013-05-28 26 views
1

我发现了很多关于如何定制listView的字体大小的解决方案,但是当我试图实现一个单选按钮列表视图时,它们都不起作用。每当我尝试和应用相同的单选按钮消失。如何更改单选按钮ListView的字体大小?

这里是我的代码:

LIST_ITEM自定义文本字体

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns: 
    android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/text1" 
    android:paddingTop="2dip" 
    android:paddingBottom="3dip" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" /> 

实现ListView控件

<ListView 
    android:id="@android:id/list" 
    android:layout_width="wrap_content" 
    android:layout_height="221dp" 
    android:layout_weight="0.00" > 

</ListView> 

<Button 
    android:id="@+id/button1" 
    android:layout_width="120dp" 
    android:layout_height="50dp" 
    android:layout_gravity="center_horizontal" 
    android:background="@drawable/button_attributes" 
    android:text="Proceed" > 
</Button> 
的XML

**(我所在的地方想创建一个RADIO LISTVIEW活动),而不该的工作任何定制

原始代码:

setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_single_choice, slips)); 

,我尝试设置代码定制列表到单选按钮不可见的适配器:

setListAdapter(new ArrayAdapter<String>(this,R.layout.list_item, slips)); 

任何帮助表示赞赏! :)

回答

2

RadioButton是看不见的,因为你have'nt在list_item.xml

添加任何单选您list_item.xml更改为

<?xml version="1.0" encoding="utf-8"?> 
<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/textAppearanceLarge" 
    android:gravity="center_vertical" 
    android:checkMark="?android:attr/listChoiceIndicatorSingle" 
    android:paddingLeft="6dip" 
    android:paddingRight="6dip" 
/> 
+0

Bang on solution。万分感谢! –

0

使用自定义列表视图到列表视图中添加单选按钮是简单而好的方法 因为如果你想要比自定义更有用的另一个改变。