I want to set background image to all rows of a GridView. I used this code:
GridView gv = (GridView) findViewById(R.id.grid); ArrayAdapter<String> aa = new ArrayAdapter<String>( this, R.layout.row, items); gv.setAdapter(aa); gv.setOnItemClickListener(this); main.xml: (I set GridView design here)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/selection" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="14pt" android:textStyle="bold" /> <GridView android:id="@+id/grid" android:layout_width="fill_parent" android:layout_height="fill_parent" android:verticalSpacing="65px" android:horizontalSpacing="5px" android:numColumns="auto_fit" android:columnWidth="100px" android:stretchMode="columnWidth" android:gravity="center" android:fastScrollEnabled="true" /> row.xml: (I set rows of Grid view design here)
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:orientation = "horizontal" android:background="@drawable/rowbg" > <TextView android:id = "@+id/label" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:textSize = "40sp" /> When i run project it forces to close program. But when I change second row as below, it runs well, ofcorse without any design for rows:
ArrayAdapter<String> aa = new ArrayAdapter<String>( this, android.R.layout.simple_list_item_1, items); Which part of my code should be changed?
Thanks
After running the program with eclipse a dialoge appears: "The application has stopped unexceptedly. Please try again." and in LogCat this message appears: "06-21 12:05:25.724: E/dalvikvm(305): Unable to open stack trace file '/data/anr/traces.txt': Permission denied"
I also try running application on Galaxy S, and I see the same error.