Android实现模仿UCweb菜单效果的方法

  /** 菜单图片 **/

  int[] menu_image_array = { R.drawable.menu_search,

  R.drawable.menu_filemanager, R.drawable.menu_downmanager,

  R.drawable.menu_fullscreen, R.drawable.menu_inputurl,

  R.drawable.menu_bookmark, R.drawable.menu_bookmark_sync_import,

  R.drawable.menu_sharepage, R.drawable.menu_quit,

  R.drawable.menu_nightmode, R.drawable.menu_refresh,

  R.drawable.menu_more };

  /** 菜单文字 **/

  String[] menu_name_array = { "搜索", "文件管理", "下载管理", "全屏", "网址", "书签",

  "加入书签", "分享页面", "退出", "夜间模式", "刷新", "更多" };

  /**

  * 构造菜单Adapter

  *

  * @param menuNameArray

  * 名称

  * @param imageResourceArray

  * 图片

  * @return SimpleAdapter

  */

  private SimpleAdapter getMenuAdapter(String[] menuNameArray,

  int[] imageResourceArray) {

  ArrayList> data = new ArrayList>();

  for (int i = 0; i < menuNameArray.length; i++) {

  HashMap map = new HashMap();

  map.put("itemImage", imageResourceArray[i]);

  map.put("itemText", menuNameArray[i]);

  data.add(map);

  }

  SimpleAdapter simperAdapter = new SimpleAdapter(this, data,

  R.layout.item_menu, new String[] { "itemImage", "itemText" },

  new int[] { R.id.item_image, R.id.item_text });

  return simperAdapter;

  }

  menuGrid = (GridView) view.findViewById(R.id.gridview);

  menuGrid.setAdapter(getMenuAdapter(menu_name_array, menu_image_array));