侧拉 DrawerLayout 懵!
来源:互联网 发布:老虎机源码 编辑:程序博客网 时间:2024/05/22 03:50
package com.lbs.xlist_view;import android.os.Bundle;import android.support.v4.widget.DrawerLayout;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.AdapterView;import android.widget.ArrayAdapter;import android.widget.FrameLayout;import android.widget.ListView;import java.util.ArrayList;import java.util.List;public class MainActivity extends AppCompatActivity { List<String> list = new ArrayList<>(); private DrawerLayout drawerLayout; private FrameLayout fl; private ListView lv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); lv = (ListView) findViewById(R.id.lv); fl = (FrameLayout) findViewById(R.id.fl); drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); initdata(); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { fragment_cla getinst = fragment_cla.getinst(list.get(i)); getSupportFragmentManager().beginTransaction().replace(R.id.fl,getinst).commit(); drawerLayout.closeDrawer(lv); } }); } private void initdata() { for (int i = 0 ; i < 10 ; i++){ list.add("drawerLayout"+i); } ArrayAdapter<String> stringArrayAdapter = new ArrayAdapter<>(MainActivity.this, android.R.layout.simple_list_item_1, list); lv.setAdapter(stringArrayAdapter); }}
package com.lbs.xlist_view;import android.os.Bundle;import android.support.annotation.Nullable;import android.support.v4.app.Fragment;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.TextView;/** * author:Created by WangZhiQiang on 2017/11/9. */public class fragment_cla extends Fragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { TextView textView = new TextView(getActivity()); Bundle bundle = getArguments(); String name = (String) bundle.get("name"); textView.setText(name); return textView ; } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); } public static fragment_cla getinst(String s) { fragment_cla fragment_cla = new fragment_cla(); Bundle bundle = new Bundle(); bundle.putString("name",s); fragment_cla.setArguments(bundle); return fragment_cla; }}//////////////////与上面的无关<?xml version="1.0" encoding="utf-8"?><android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawe" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.lbs.zhoukaomoni.MainActivity"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <com.bwie.xlistviewlibrary.View.XListView android:id="@+id/xlistview1" android:layout_width="wrap_content" android:layout_height="wrap_content"></com.bwie.xlistviewlibrary.View.XListView> </LinearLayout> <ListView android:id="@+id/drawe_lv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="start" android:choiceMode="singleChoice" android:clickable="true" /></android.support.v4.widget.DrawerLayout>
阅读全文
0 0
- 侧拉 DrawerLayout 懵!
- DrawerLayout侧拉
- DrawerLayout侧拉+TabLayout
- DrawerLayout侧拉
- drawerlayout 侧拉菜单
- 侧拉 DrawerLayout
- DrawerLayout侧拉
- DrawerLayout 侧拉
- Drawerlayout侧拉菜单
- 侧拉DrawerLayout
- DrawerLayout侧拉
- DrawerLayout实现侧拉索引
- 侧拉DrawerLayout 的使用
- 使用DrawerLayout实现侧拉菜单
- DrawerLayout来实现侧拉菜单效果
- 使用DrawerLayout实现侧拉菜单
- 使用DrawerLayout实现侧拉菜单
- DrawerLayout的侧拉范围方法,
- 途游笔试
- Django框架中的Context使用
- 计算机网络基础(转载)
- POJ-2456 Aggressive cows
- 转载--spring配置文件详解
- 侧拉 DrawerLayout 懵!
- 极其stupid的期中考试
- Hdu 5792 World is Exploding
- JSONP的跨域请求
- unity用于android上的旋转缩放脚本
- hibernate_商城关系表的建立
- 二分查找
- Android开发自定义圆角带点击效果的Button
- 习题6.15