Ant*_*ato 5 android android-fragments
在我的应用程序中,我有一个实现ListFragment.OnSelectedListener的FragmentActivity.
ListFragment使用自定义适配器来扩展customrow.xml布局.
我想在列表中更改分隔符颜色和高度.
我想我需要使用android:divider属性,但不知道具体如何.
我尝试将它放在FragmentActivity的布局和customrow.xml布局中,但它不起作用......
customrow.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="@drawable/item_selector"
android:divider="#f19000" >
...textview and imageview...
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
编辑:解决方案
谢谢大家的帮助!问题是我没有为我的ListFragment夸大自定义xml ...
所以创建一个新的list_fragment.xml并在我的ListFragment中添加这样的东西就可以了:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.list_fragment, null);
return view;
}
Run Code Online (Sandbox Code Playgroud)
list_fragment.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#f19000"
android:dividerHeight="1dip" >
</ListView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
此外,android:id ="@ android:id/list"是必需的,将id更改为其他内容会导致崩溃.
| 归档时间: |
|
| 查看次数: |
5664 次 |
| 最近记录: |