Android抽屉菜单SlidingDrawer 简单使用
发布时间:2020-05-24 20:24:35 所属栏目:Java 来源:互联网
导读:Android抽屉菜单SlidingDrawer 简单使用
|
下面是脚本之家 jb51.cc 通过网络收集整理的代码片段。 脚本之家小编现在分享给大家,也给大家做个参考。 <?xml version="1.0" encoding="utf-8"?><!-- 需要设置SlidingDrawer的handle和content的id --> <SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/slidingdrawer" android:layout_width="match_parent" android:layout_height="match_parent" android:content="@+id/content" android:handle="@+id/handle" android:orientation="horizontal" > <!-- 设置handle,来处理滑动抽屉 --> <ImageButton android:id="@id/handle" android:layout_width="50dp" android:layout_height="50dp" android:src="@drawable/ic_launcher" /> <!-- 设置内容View --> <RelativeLayout android:id="@id/content" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#F0F0F0" > <TextView android:id="@+id/show_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical|center_horizontal" android:text="简单抽屉效果" android:textColor="#333333" android:textSize="18sp" /> <ListView android:id="@+id/lv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/show_tv" > </ListView> </RelativeLayout> public class DrawerAdpater extends BaseAdapter { List<String> list; LayoutInflater inflater; public MyAdpater(Context context,List<String> list) { this.list = list; this.inflater = LayoutInflater.from(context); } public int getCount() { return list.size(); } public long getItemId(int position) { return position; } public View getView(int position,View convertView,ViewGroup parent) { if (convertView == null) { convertView = inflater.inflate(R.layout.item,null); } TextView textView = (TextView) convertView.findViewById(R.id.text); textView.setText(list.get(position)); return convertView; } @Override public Object getItem(int position) { return list.get(position); } } 以上是脚本之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。 如果觉得脚本之家网站内容还不错,欢迎将脚本之家网站推荐给程序员好友。 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
