The first step, the layout file
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" match_parent " android:layout_height=" Match_parent " Tools:context= ". Joketabhostactivity " android:orientation=" vertical " > <gridview android:id=" @+id/ GridView " android:listselector=" @android: color/transparent " android:layout_width=" Fill_parent " android:layout_height= "Fill_parent" android:columnwidth= "90DP" android:gravity= "center" Android : numcolumns= "Auto_fit" android:layout_margintop= "10DP" android:stretchmode= "ColumnWidth" > </GridView></LinearLayout>
The second step is to invoke the initialize grid in your activity
GridView GridView = (GridView) Findviewbyid (R.id.gridview); arraylist> arg0, View arg1, int arg2,long arg3) {int index = ARG2 + 1;//ID is starting from 0, so it needs to be +1if (index = = 1) {Intent Intent = new int ENT (); Intent.setclass (Mainactivity.this,closetabhostactivity.class); startactivity (intent);} if (index = = 2) {Intent Intent = new Intent (); Intent.setclass (Mainactivity.this, xlistviewactivity.class); startactivity (intent);//showinfo ("Working in code ...
");//Finish ()//Stop the current activity, assuming not to write, then press the return key will jump back to the original activity}if (index = = 3) {Showinfo (" look forward to your suggestions, good advice please q 649175826 ");}});
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
"Android" Nine grid implementation