【发布时间】:2019-03-03 15:14:33
【问题描述】:
我必须为列表视图设置背景图像。不为每一行设置图像。必须为整个屏幕设置背景图像并在加载列表视图时选择单选按钮。这意味着应该选择第一个选项
这是我的代码。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sales_routes); // **Added edited**
ArrayList<Object> routeList = getWmRoute();
ArrayList<String> routhPath = new ArrayList<String>();
for(int i = 0; i<routeList.size();i++){
routhPath.add(((WMRoute) routeList.get(i)).getDescription());
}
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_two_column, R.id.FROM_CELL, routhPath));
ListView list=getListView();
}
我的 xml 文件是 (list_two_column.xml)
<?xml version="1.0" encoding="utf-8"?>
<!-- row.xml -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingTop="4dip"
android:paddingBottom="6dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<!--android:background="@drawable/wallpaper" -->
<RadioButton android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</RadioButton>
<TextView android:id="@+id/FROM_CELL"
android:layout_width="70dip"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
新添加 - sales_routes.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="6dip"
android:layout_marginRight="6dip"
android:dividerHeight="2dip"
android:background="@drawable/wallpaper" />
</LinearLayout>
目前它的显示列表,问题是图片背景图片
要求
- 加载列表视图时选择单选按钮。这意味着第一个选项应该选择
【问题讨论】:
-
如果您转到具有列表视图的 XML 并使用这些 android:background="@drawable/wallpaper",您可以将背景设置为列表视图
-
我无法在
This .. -
谢谢。它现在工作正常。但是必须选择单选按钮。
-
谢谢。它的背景图像设置工作正常。现在问题是突出显示第一行并选择单选按钮。请帮助我