跟着郑平老师做通讯录小项目时学到布局界面底部的控件

界面底部整体是一个GirdView  一行一共五列,每一项是上面图片下面是Text  用SiampleAdapter进行加入  GirdView中每一项的布局如下:  <?xml version="1.0" encoding="utf-8"?>  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"      android:layout_width="fill_parent"      android:layout_height="wrap_content"      android:orientation="horizontal"      android:paddingBottom="5dip" >         <ImageView          android:id="@+id/item_image"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:layout_centerHorizontal="true" />         <TextView          android:id="@+id/item_text"          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:layout_below="@+id/item_image"          android:layout_centerHorizontal="true" />     </RelativeLayout>

Java代码如下:

package com.jiangqq;     import java.util.ArrayList;  import java.util.HashMap;  import java.util.List;  import java.util.Map;     import android.app.Activity;  import android.os.Bundle;  import android.view.Gravity;  import android.widget.GridView;  import android.widget.SimpleAdapter;     public class GirdViewActivity extends Activity  {  private GridView gv_button_menu;     @Override  protected void onCreate(Bundle savedInstanceState) {  // TODO Auto-generated method stub  super.onCreate(savedInstanceState);  setContentView(R.layout.main);  loadButtonMenu();  }     private void loadButtonMenu() {  gv_button_menu = (GridView) this.findViewById(R.id.gv_buttom_menu);  gv_button_menu.setBackgroundResource(R.drawable.channelgallery_bg);  // 设置每行的列数  gv_button_menu.setNumColumns(5);  gv_button_menu.setGravity(Gravity.CENTER);  gv_button_menu.setVerticalSpacing(10);  gv_button_menu.setHorizontalSpacing(10);  List data = new ArrayList();  Map map = new HashMap();  map.put("itemImage", R.drawable.menu_new_user);  map.put("itemText", "添加");  data.add(map);  map = new HashMap();  map.put("itemImage", R.drawable.menu_search);  map.put("itemText", "查找");  data.add(map);  map = new HashMap();  map.put("itemImage", R.drawable.menu_delete);  map.put("itemText", "删除");  data.add(map);  map = new HashMap();  map.put("itemImage", R.drawable.controlbar_showtype_list);  map.put("itemText", "菜单");  data.add(map);  map = new HashMap();  map.put("itemImage", R.drawable.menu_exit);  map.put("itemText", "退出");  data.add(map);     SimpleAdapter adapter = new SimpleAdapter(this, data,  R.layout.item_menu, new String[] { "itemImage", "itemText", },  new int[] { R.id.item_image, R.id.item_text });  gv_button_menu.setAdapter(adapter);  }  }   最后说一下 郑平老师讲的也不错,这两天连续做了三个小项目,也学到了很多东西,要好总结一下

你可能感兴趣的:(android,HashMap,layout,button,menu,通讯)