【发布时间】:2014-03-10 10:58:31
【问题描述】:
所以我有一个应用程序,它使用一些按钮来进行不同的活动。在它们下方,我有图像按钮,我想使用其中的 2 个来打开 2 个不同的滑动菜单。我已经阅读了来自here 的所有关于滑动菜单的内容,但它只显示了使用滑动菜单的某种方式。
所以活动的代码是:
public class ChooseCategory extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_choose_category);
}
我的 xml 代码是:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#BE2625"
android:orientation="vertical">
<Button
android:id="@+id/fancy"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/fancy"
android:textColor="#FFFFFF"
android:background="@drawable/button4"
/>
<Button
android:id="@+id/chipchop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/chipchop"
android:textColor="#FFFFFF"
android:background="@drawable/button4"
/>
<Button
android:id="@+id/pizza"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/pizza"
android:textColor="#FFFFFF"
android:background="@drawable/button4"
/>
<Button
android:id="@+id/asian"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/asian"
android:textColor="#FFFFFF"
android:background="@drawable/button4"
/>
<Button
android:id="@+id/indian"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/indian"
android:textColor="#FFFFFF"
android:background="@drawable/button4"
/>
<Button
android:id="@+id/kebab"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/kebab"
android:textColor="#FFFFFF"
android:background="@drawable/button4"
/>
<Button
android:id="@+id/other"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/other"
android:textColor="#FFFFFF"
android:background="@drawable/button4"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/ll_menu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:gravity="bottom"
android:background="#BE2620" >
<!-- contentDescription tags added to remove related warnings -->
<ImageButton
android:id="@+id/btn_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:background="@null"
android:src="@drawable/ic_launcher"
/>
<ImageButton
android:id="@+id/btn_book"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:background="@null"
android:src="@drawable/ic_launcher"
/>
<ImageButton
android:id="@+id/btn_find_us"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:background="@null"
android:src="@drawable/ic_launcher"
/>
<ImageButton
android:id="@+id/btn_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:background="@null"
android:src="@drawable/ic_launcher"
/>
</LinearLayout>
</LinearLayout>
<!-- Listview to display slider menu -->
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:dividerHeight="1dp"
android:background="#FFFFFF"/>
</RelativeLayouts>
关于如何使用该代码或其他代码来单击 ImageButton 并打开滑动菜单的任何帮助?
【问题讨论】:
-
您想通过单击图像视图来打开滑动菜单。这是你想问的吗?
-
如何从 ImageButton 打开滑动菜单。因为在上面的链接上,我无法理解如何将它用于 Imagebutton。
-
操作栏上的图标。它被称为导航抽屉。
标签: android android-layout slidingmenu slidingdrawer