Android 实现底部菜单栏
16lz
2021-01-23
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>
更多相关文章
- Android ListView实现Table行列效果
- 设置ListView每条数据之间的间隔
- Android 应用程序退出后不在运行列表中显示的方法
- android 设置应用退出后不在运行列表中显示
- Android四大布局之表格布局行列位置控制
- TextView——行间距与字母间隔
- Android 源码修改按键长按响应间隔
- Android:解决RadioGroup中RadioButton的图片自定义及每项间隔距离
- 如何实现图片的动态切换(间隔几秒就切换下一张)