I have used this code for the row layout:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@drawable/bckimage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:textSize="16sp" >
</TextView>
and this is for the class that builds the list:
public class ListTestActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
String[] myArray = new String[] {...};
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.listlayout,myArray));
ListView listView = getListView();
listView.setCacheColorHint(0);
listView.setBackgroundResource(R.drawable.bckimage);
listView.setTextFilterEnabled(true);
listView.setOnItemClickListener(new OnItemClickListener() {
//. . .
});
}
}
This shows an image for each row, not for the whole background. How can I add a single image for background? I saw several methods in here also but nothing worked.
Set the image as the background for the
ListViewelement instead:Your list rows probably hide the background image. Also add: