I defined a layout view in a .xml file called menu_list_slide_lateral.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linear_menu_slide"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/btnSliBebe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/bebe" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/foto_diario" />
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/consejos" />
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/ajustes" />
</LinearLayout>
Im creating the SlidingMenu from code:
setBehindContentView(R.layout.menu_list_slide_lateral);
setSlidingActionBarEnabled(true);
slideMenu = getSlidingMenu();
slideMenu.setMode(SlidingMenu.LEFT);
slideMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
slideMenu.setShadowWidthRes(R.dimen.shadow_width);
slideMenu.setBehindOffset(100);
slideMenu.setFadeDegree(0.35f);
And mi activity extends from SlidingFragmentActivity:
public class TimelineActivity extends SlidingFragmentActivity
It shows perfectly the menu, but i want to do some actions when the user chooses an option from the menu:
For example, i want to open another activity when i choose the "Bebe" option. I tried to set a onClick event to that button but it doesn't seem to work, it makes nothing:
inflater = getLayoutInflater();
item = inflater.inflate(R.layout.menu_list_slide_lateral, null);
btnSliBebe = (Button) item.findViewById(R.id.btnSliBebe);
btnSliBebe.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
Log.e(TAG, "boton bebe");
}
});
How can i access that buttons and asign them a event?
Thanks!