2017-02-10 7 views
0

: 'Single Action'のhttps://www.google.com/design/spec-wear/components/action-drawer.html#action-drawer-usage 、ActionDrawerは展開できません。 私の質問は、その行動を達成する方法ですか?
私はWearableActionDrawerWearableDrawerViewを試しました。 また、lockDrawerClosed()というメソッドを試しましたが、引き出しが引き続きクリックで開きます。 ご協力いただきありがとうございます! :)1つのアクションでActionDrawerを作成する方法Googleガイドラインで指摘されている

編集:
[OK]をクリックすると、引き出しが開かないようにするソリューションが見つかりました。私は現在WearableActionDrawerを使用しており、lockDrawerClosed()を呼び出しています。しかし、今私はpeek_viewを正しく変更する方法がわかりません。

ImageViewを含むカスタムビューLinearLayoutを作成しました。私はこのビューをmWearableActiondrawer.setPeekView(myView)に使用しています。しかし、問題は、ビューが適切に表示されないことです。一番下に空のActionDrawerが表示されます。 しかしclicklistenerが働いてます。..ここ

は私のコードです:

// Bottom Action Drawer 
mWearableActionDrawer = (WearableActionDrawer) findViewById(R.id.bottom_action_drawer); 
mWearableActionDrawer.lockDrawerClosed(); 

LayoutInflater layoutInflater = 
    (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); 
LinearLayout view = 
    (LinearLayout) layoutInflater.inflate(R.layout.action_drawer_peek_view, null); 

mWearableActionDrawer.setPeekContent(view); 

view.setOnClickListener(new View.OnClickListener() { 
    @Override public void onClick(View v) { 
    Toast.makeText(getApplicationContext(), "Hello", Toast.LENGTH_SHORT).show(); 
    } 
}); 

レイアウト:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 
    android:id="@+id/action_drawer_peek_view" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 
    android:background="@color/wearable_primary" 
 
    android:orientation="vertical" 
 
    > 
 
    <ImageView 
 
     android:layout_width="wrap_content" 
 
     android:layout_height="wrap_content" 
 
     android:layout_gravity="center_horizontal" 
 
     android:padding="10dp" 
 
     android:src="@drawable/fill_1_copy" 
 
     /> 
 
</LinearLayout>

私はここで間違ってやっているの任意の考え?ありがとう!

答えて

0

私はこれと比べてエラーが発生していませんsample code。あなたのアクション・ドロワのアクションが1つしかない場合は、(カスタム)Viewを使用して、コンテンツの先頭を覗くことができます(mWearableActionDrawer.setPeekContent(View))。ユーザーがViewをクリックしたことを処理するクリックリスナーを設定してください。

また、mWearableDrawerLayout.peekDrawer(Gravity.BOTTOM);を試してみることもできます。引き出しの内容を初期化する方法を示すdocumentationに基づいて実装をもう一度確認してください。

関連する問題