九宫图的实现方式
private GridView mGridView01;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mGridView01 = (GridView)findViewById(R.id.myGridView1);
/* 9个元素,以3列方式呈现(3x3) */
mGridView01.setNumColumns(3);
/* 9个字符串数组 */
mGames2 = new String[]
{
getResources().getString(R.string.str_list1),
getResources().getString(R.string.str_list2),
getResources().getString(R.string.str_list3),
getResources().getString(R.string.str_list4),
getResources().getString(R.string.str_list1),
getResources().getString(R.string.str_list2),
getResources().getString(R.string.str_list3),
getResources().getString(R.string.str_list4),
getResources().getString(R.string.str_list1)
};
aryAdapter1 = new ArrayAdapter<String>
(EX04_18.this, R.layout.simple_list_item_1_small, mGames2);
mGridView01.setAdapter(aryAdapter1);
用上下左右来控制九宫图
android:nextFocusLeft="@+id/ImageButton19"
android:nextFocusRight="@+id/ImageButton12"
android:nextFocusUp="@+id/ImageButton91"
android:nextFocusDown="@+id/ImageButton21"