Doesn't work for all content windows
This is my code:
public class MainActivity extends FragmentActivity implements View.OnClickListener { private static final int TOAST_DURATION = 4000;
private boolean isBackClicked = false;
public static Typeface font;
private SlidingMenu menu;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_dashboard);
initializeIcons(MainActivity.this);
// configure the SlidingMenu
menu = new SlidingMenu(this);
menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menu.setFadeDegree(0.35f);
menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menu.setMenu(R.layout.menu_frame);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.menu_frame, new MenuFragment())
.commit();
}
@Override
public void onBackPressed() {
if (menu.isMenuShowing()) {
menu.showContent();
} else {
if (isBackClicked) {
MainActivity.this.finish();
} else {
isBackClicked = true;
Toast.makeText(MainActivity.this, Const.CLICK_BACK_TO_EXIT, TOAST_DURATION).show();
Log.i("isBC Toast", String.valueOf(isBackClicked));
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
isBackClicked = false;
Log.i("isBC Runnable", String.valueOf(isBackClicked));
}
}, TOAST_DURATION / 2); //divide by 2 because Toast spend a half time to animation
}
}
}
@Override
public void onClick(View view) {
//do nothing
}
}
main_dashboard:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="@drawable/main_top_top"
android:id="@+id/relativeLayout">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/menu" android:textColor="@color/buttonColor" android:layout_alignParentRight="false"
android:background="@drawable/menu_icon" android:layout_centerInParent="true"
android:layout_marginRight="10dp" android:layout_alignParentLeft="true"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_below="@+id/relativeLayout">
<com.google.dashboard.DashboardLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1">
<ImageView android:id="@+id/messages"
style="@style/DashboardIcon"
android:src="@drawable/icon_messages"/>
<ImageView android:id="@+id/friends"
style="@style/DashboardIcon"
android:src="@drawable/icon_friends"/>
<ImageView android:id="@+id/square"
style="@style/DashboardIcon"
android:src="@drawable/icon_square"/>
</com.google.dashboard.DashboardLayout>
</RelativeLayout>
Sliding work on first layout but doesn't work on second. I don't understand why
I don't really understand what the problem is. Sliding doesn't work where?
Yes, sliding
on
it's work, but on
<ImageView android:id="@+id/messages"
style="@style/DashboardIcon"
android:src="@drawable/icon_messages"/>
<ImageView android:id="@+id/friends"
style="@style/DashboardIcon"
android:src="@drawable/icon_friends"/>
<ImageView android:id="@+id/square"
style="@style/DashboardIcon"
android:src="@drawable/icon_square"/>
</com.google.dashboard.DashboardLayout>
it isn't.Though there are in one LinearLayout
Making the layout clickable (android:clickable="true") have solved a similar problem for me. See: https://github.com/jfeinstein10/SlidingMenu/issues/181
pfihl, thanks, it's work for me. It's strangely that the button on first relativeLayout make it clickable