首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SlidingPaneLayout isSlideable()方法不起作用

SlidingPaneLayout isSlideable()方法不起作用
EN

Stack Overflow用户
提问于 2014-07-06 22:09:34
回答 1查看 759关注 0票数 0

我有滑动窗格布局

代码语言:javascript
复制
<android.support.v4.widget.SlidingPaneLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/slidingPaneLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <fragment
        android:id="@+id/first_fragment"
        android:layout_width="@dimen/first_pane_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        class="com.example.example.FirstFragment"
        tools:layout="@layout/fragment_first" />

    <fragment
        android:id="@+id/second_fragment"
        android:layout_width="@dimen/second_pane_width"
        android:layout_weight="1"
        android:layout_height="match_parent"
        class="com.example.example.SecondFragment"
        tools:layout="@layout/fragment_second`enter code here`" />

</android.support.v4.widget.SlidingPaneLayout>

这是我的onCreate方法:

代码语言:javascript
复制
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    slidingPaneLayout = (SlidingPaneLayout) findViewById(R.id.slidingPaneLayout);
    slidingPaneLayout.setPanelSlideListener(this);
    slidingPaneLayout.setParallaxDistance(PARALLAX_DISTANCE);
    slidingPaneLayout.setShadowDrawable(getResources().getDrawable(R.drawable.shadow));

    secondFragment = (SecondFragment) getFragmentManager().findFragmentById(R.id.second_fragment);
    firstFragment = (FirstFragment) getFragmentManager().findFragmentById(R.id.first_fragment);

    if (savedInstanceState == null) {
        firstFragment.selectItem(0);
        if (slidingPaneLayout.isSlideable()) {
            slidingPaneLayout.openPane();
            onPanelOpened(null);
        }   
    }
    if (slidingPaneLayout.isSlideable()) Log.d(TAG, "isSlideable");

但是slidingPaneLayout.isSlideable()总是返回false。我尝试在手机和模拟器(Nexus7)上运行这个应用程序,但它总是返回相同的结果。在调试模式下,( slidingPaneLayout对象的) mCanSlide变量始终为false。

有人能告诉我我做错了什么吗?谢谢。

EN

回答 1

Stack Overflow用户

发布于 2014-09-27 18:13:53

检查

代码语言:javascript
复制
isSlaydeble=false;

slidingPaneLayout = (SlidingPaneLayout) findViewById(R.id.dl_menu);
slidingPaneLayout.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {
            @Override
            public void onPanelSlide(View view, float v) {
                isSlaydeble=true;
            }

            @Override
            public void onPanelOpened(View view) {
            }

            @Override
            public void onPanelClosed(View view) {
            }
        });



<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SlidingPaneLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/dl_menu"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <ListView
            android:id="@+id/lv_menu"
            android:layout_width="240dp"
            android:layout_gravity="left"
            android:layout_height="match_parent"
            android:background="#FFFFFF"
            />

    <FrameLayout
            android:id="@+id/fl_fragment_container"
            android:layout_width="match_parent"
            android:background="#0000FF"
            android:layout_gravity="right"
            android:layout_height="match_parent">
    </FrameLayout>


</android.support.v4.widget.SlidingPaneLayout>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24596710

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档