我想在ListActivity中自定义内置列表。我宁愿在我的资源范围内做这件事,而不是动态地去做。
我一直在研究这个问题,很难解决。有一个问题,Cant change listview font in listactivity,但没有优雅的答案。
我有一个列表:
<ListView
style="@style/ListView"
android:id="@android:id/list"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>使用样式资源:
<style name="ListView">
<item name="android:textSize">20sp</item>
<item name="android:textColor">#FFF</item>
...
</style>这些样式适用于其他元素。只有当我使用android:id="@android:id/list"时才会这样。文本的默认设置将重写任何自定义设置。
任何帮助都是非常感谢的。
发布于 2015-07-07 05:55:36
你可以通过这样做来实现。
在布局中创建listview_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="20sp"
android:textStyle="italic"
android:textColor="#00ffff" />
</LinearLayout>在代码中实现数组适配器
ArrayAdapter<String> listAdapter = new ArrayAdapter <String>(this,
R.layout.listview_row, R.id.textList, yourListValue);
setListAdapter(listAdapter);https://stackoverflow.com/questions/31259894
复制相似问题