ClickListener的滑动菜单项 [英] ClickListener for Slide Menu items
本文介绍了ClickListener的滑动菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我定义在一个名为profile_sliding_menu.xml .xml文件的布置图:
I defined a layout view in a .xml file called profile_sliding_menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#b5b5b5" />
<TextView
android:id="@+id/pMenuProfileInformation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_profile_information"
android:drawablePadding="5dp"
android:gravity="center"
android:paddingLeft="5dp"
android:paddingTop="3dp"
android:clickable="true"
android:text="@string/pMenuProfileInformation"
android:textAppearance="?android:attr/textAppearanceMedium" />
..........
</LinearLayout>
我可是从code创建SlidingMenu:
Im creating the SlidingMenu from code:
SlidingMenu menu;
menu = new SlidingMenu(this);
menu.setMode(SlidingMenu.LEFT);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setShadowWidthRes(R.dimen.shadow_width);
menu.setShadowDrawable(R.drawable.shadow);
menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menu.setFadeDegree(0.35f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setMenu(R.layout.profile_sliding_menu);
它完美地展示了菜单,但我想,当用户从选择菜单中的选项做一些动作。
我怎样才能访问按钮和ASIGN他们一个事件?
It shows perfectly the menu, but i want to do some actions when the user chooses an option from the menu. How can i access that buttons and asign them a event?
谢谢!
推荐答案
我做这样的事情,和所有正常工作:
I make something like this, and all work fine:
findViewById(R.id.pMenuProfileInformation).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(),
"blablabal", Toast.LENGTH_SHORT).show();
}
});
这篇关于ClickListener的滑动菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文