スライド ペイン レイアウトがあります
<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 メソッドです:
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");
しかし、slidePaneLayout.isSlideable() は常に false を返します。電話とエミュレータ (Nexus 7) でアプリを実行しようとしましたが、常に同じ結果が返されます。デバッグ モードでは、(slidePaneLayout オブジェクトの) mCanSlide 変数は常に false です。
誰が私が間違っているのか教えてもらえますか? ありがとう。