咨询一个关于DrawerLayout的问题
看了很多帖子发现在使用DrawerLayout的时候基本都是用的官方提供的demo或是大神分享的教程里通过ActionBarDrawerToggle来启动或关闭弹出的抽屉菜单。
那请问我能否通过点击第一个主layout里的button来开启/关闭抽屉栏呢。
xml 布局如下:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- The main content view -->
<include layout="@layout/content_layout" />
<ListView
android:id="@+id/left_drawer"
android:layout_width="290dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
现在直接通过,获取主layout的view 然后响应点击事件并未成功。 请问该如何操作呢?
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.content_layout, null);
i_report_booklistbtn = (ImageButton) view
.findViewById(R.id.i_report_booklistbtn);
i_report_booklistbtn.setOnClickListener(this);