我想为我的List视图设置背景。我已从可绘制的图像,并将其设置为布局文件的背景,然后它给出的结果如下屏幕截图无法将背景设置为ListView
当我只是删除背景获取我需要的东西,但没有背景。 和屏幕截图是 是否有任何其他语法为ListView设置背景。
而且我的布局代码是
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:text="@+id/TextView01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/label"
android:textColor="#FF0000"
android:textSize="30px"></TextView>
</LinearLayout>
And my java code and that is
String[] names = new String[] { "India", "Malaysia" };
// Use your own layout and point the adapter to the UI elements which
// contains the label
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.screen3,
R.id.label, names));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// Get the item that was clicked
Object o = this.getListAdapter().getItem(position);
String keyword = o.toString();
if(keyword.equals("India"))
{
Intent ima1=new Intent(screen3.this,new21.class);
startActivity(ima1);
}
else
{
Intent ima2=new Intent(screen3.this,new22.class);
startActivity(ima2);
}
Toast.makeText(this, "You selected: " + keyword, Toast.LENGTH_LONG)
.show();
}
而最后,我需要的是我想与适当的列表视图背景图像显示了一个又一个列表项。在此先感谢 }
你在哪里设置背景? –
@radha是否所有ListView的背景都应该相同? – Venky
我已经在xml文件中做了android:background =“@ drawable/screen6” – radha