menu.setNumColumns(5);// 设置每行列数menu.setGravity(Gravity.CENTER);// 位置居中menu.setVerticalSpacing(10);// 垂直间隔menu.setHorizontalSpacing(10);// 水平间隔menu.setAdapter(getMenuAdapter(a));menu.setOnItemClickListener(new OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {// TODO Auto-generated method stubswitch (arg2) {case 0:break;case 1:break;case 2:break;case 3:break;case 4:break;}}});}

private ListAdapter getMenuAdapter(String[] a2) {// TODO Auto-generated method stubArrayList<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();for (int i = 0; i < a2.length; i++) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("itemText", a2[i]);data.add(map);}SimpleAdapter simperAdapter = new SimpleAdapter(this, data,R.layout.item, new String[] { "itemText" },new int[] { R.id.item_text });return simperAdapter;}

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/RelativeLayout_Item"android:layout_width="fill_parent" android:layout_height="wrap_content"android:paddingBottom="5dip"><TextView android:id="@+id/item_text"android:layout_centerHorizontal="true" android:layout_width="wrap_content"android:layout_height="wrap_content" android:textColor="#FFFFFFFF"></TextView></RelativeLayout>

更多相关文章

  1. Android ListView实现Table行列效果
  2. 设置ListView每条数据之间的间隔
  3. Android 应用程序退出后不在运行列表中显示的方法
  4. android 设置应用退出后不在运行列表中显示
  5. Android四大布局之表格布局行列位置控制
  6. TextView——行间距与字母间隔
  7. Android 源码修改按键长按响应间隔
  8. Android:解决RadioGroup中RadioButton的图片自定义及每项间隔距离
  9. 如何实现图片的动态切换(间隔几秒就切换下一张)

随机推荐

  1. Android中的动画
  2. Android点击两次返回键,退出应用程序
  3. Android中使用Animation实现控件的动画效
  4. Android(安卓)预置APK的权限授予
  5. 使用ddmlib实现android 性能监控
  6. android binder c++层 - 回调客户端服务
  7. Android中自定义Checkbox
  8. Android下载网络图片到本地
  9. Android(安卓)Developers:日历提供者
  10. Android(安卓)Asynchronous Http Client