我很困擾如何做到以下要求。如何在按下按鈕時顯示像這樣的選項菜單?
我需要做一個簡單的屏幕有兩個按鈕,就像這樣:
在屏幕的部分已經完成。
對我來說最困難的事情是在按下按鈕時使兩個按鈕 的行爲。在這種情況下,他們必須表現出選項菜單下面 這樣的:
按鈕按下1:
按鈕按下2:
我沒有開始編程菜單,但如果它有幫助,這是 屏幕的佈局(沒有按鈕)。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/grayBackgound"
tools:context=".MenuActivity" >
<include android:layout_width="match_parent" layout="@layout/header" />
<include android:layout_width="match_parent" layout="@layout/loggedin_subheader"/>
</LinearLayout>
用於報頭的佈局:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/header"
android:contentDescription="@string/header"
/>
<ImageButton
android:id="@+id/btnClose"
android:src="@drawable/btn_close"
android:contentDescription="@+string/salir"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="260dp"
/>
</FrameLayout>
的子報頭的佈局基本相同。
我只是需要幫助,使每個按鈕的選項菜單。
在此先感謝!
謝謝Siddharth!我會嘗試將這個例子改編成我的用例! – Lucas 2013-03-10 15:00:00
@Lucas:很高興有幫助。祝你好運。 :-) – 2013-03-10 15:01:30