主界面Tabwidget+九宫格
Java代码
public class MainView extends TabActivity implements OnGestureListener,
OnTouchListener {
TabHost tabHost;
Button tab1_btn1;
private GridView gv1 = null;
private GridView gv2 = null;
private GridView gv3 = null;
private GridView gv4 = null;
// 主界面上每一项的名字
String[] item_name1 = { "公文处理", "办公邮件" };// 单项的名字
int[] item_images1 = { R.drawable.tab11, R.drawable.tab12 };// 单项的图片
String[] item_name2 = { "通知公告" };// 单项的名字
int[] item_images2 = { R.drawable.tab21 };// 单项的图片
String[] item_name3 = { "通讯录", "日常安排" };// 单项的名字
int[] item_images3 = { R.drawable.tab31, R.drawable.tab32 };// 单项的图片
String[] item_name4 = { "系统配置", "数据同步", "程序更新" };// 单项的名字
int[] item_images4 = { R.drawable.tab41, R.drawable.tab42, R.drawable.tab43 };// 单项的图片
private ViewFlipper viewFlipper;
private GestureDetector gestureDetector;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉标题栏
setContentView(R.layout.main);
setTitle("主界面");
setTitleColor(Color.YELLOW);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);// 去掉信息栏注意,这个设置必须放在设置布局前面,不然会报错
// 适配器
SimpleAdapter 易做图Adapter = new SimpleAdapter(this, //
GetDataList.getDataList(item_name1, item_images1), //
R.layout.mainview_item,//
new String[] { "images", "name" }, //
new int[] { R.id.item_image, R.id.item_text });//
gv1 = (GridView) this.findViewById(R.id.gridview1);
SetGridView.setGridView(gv1, 3, 10, 10, 0);// 设置GridView的相应参数
gv1.setAdapter(易做图Adapter);
易做图Adapter = new SimpleAdapter(this, GetDataList.getDataList(
item_name2, item_images2), R.layout.mainview_item,
new String[] { "images", "name" }, new int[] { R.id.item_image,
R.id.item_text });
gv2 = (GridView) this.findViewById(R.id.gridview2);
SetGridView.setGridView(gv2, 3, 10, 10, 0);
gv2.setAdapter(易做图Adapter);
易做图Adapter = new SimpleAdapter(this, GetDataList.getDataList(
item_name3, item_images3), R.layout.mainview_item,
new String[] { "images", "name" }, new int[] { R.id.item_image,
R.id.item_text });
gv3 = (GridView) this.findViewById(R.id.gridview3);
SetGridView.setGridView(gv3, 3, 10, 10, 0);
gv3.setAdapter(易做图Adapter);
易做图Adapter = new SimpleAdapter(this, GetDataList.getDataList(
item_name4, item_images4), R.layout.mainview_item,
new String[] { "images", "name" }, new int[] { R.id.item_image,
R.id.item_text });
gv4 = (GridView) this.findViewById(R.id.gridview4);
SetGridView.setGridView(gv4, 3, 10, 10, 0);
gv4.setAdapter(易做图Adapter);
tabHost = getTabHost();
/* 自定义标签 */
setIndicator(R.drawable.tab1, "办公", R.id.tab1);
setIndicator(R.drawable.tab2, "资讯", R.id.tab2);
setIndicator(R.drawable.tab3, "联系", R.id.tab3);
setIndicator(R.drawable.tab4, "设置", R.id.tab4);
tabHost.setCurrentTab(0);// 默认显示tab1
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
// 选项卡单击事件
public void onTabChanged(String tabId) {
Toast.makeText(MainView.this, tabId, Toast.LENGTH_LONG).show();
}
});
 
补充:移动开发 , Android ,