Skip to content

Commit

Permalink
add title bar menu button
Browse files Browse the repository at this point in the history
  • Loading branch information
SpecialCyCi committed Dec 22, 2013
1 parent 350ba20 commit 62ef1ef
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions ResideMenuDemo/res/drawable/titlebar_menu_selector.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@drawable/title_bar_menu_on" />
<item android:state_focused="true" android:drawable="@drawable/title_bar_menu" />
<item android:drawable="@drawable/title_bar_menu" />
</selector>
29 changes: 21 additions & 8 deletions ResideMenuDemo/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,27 @@
android:layout_height="3dp"
android:background="#2ea3fe"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="7dp"
android:text="RESideMenu DEMO"
android:textSize="24sp"
android:textColor="#999999"
android:layout_gravity="center"/>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<Button
android:layout_width="28dp"
android:layout_height="28dp"
android:background="@drawable/titlebar_menu_selector"
android:id="@+id/title_bar_menu"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="10dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="7dp"
android:text="RESideMenu DEMO"
android:textSize="24sp"
android:textColor="#999999"
android:layout_gravity="center"/>
</FrameLayout>

<ImageView
android:layout_width="match_parent"
Expand Down
2 changes: 1 addition & 1 deletion ResideMenuDemo/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<resources>
<style name="fragment_text">
<item name="android:textColor">#ffacacac</item>
<item name="android:textSize">20sp</item>
<item name="android:textSize">25sp</item>
</style>
</resources>
10 changes: 8 additions & 2 deletions ResideMenuDemo/src/com/special/ResideMenuDemo/MenuActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,27 @@ private void setUpMenu() {
resideMenu.addMenuItem(itemProfile);
resideMenu.addMenuItem(itemCalendar);
resideMenu.addMenuItem(itemSettings);

findViewById(R.id.title_bar_menu).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
resideMenu.openMenu();
}
});
}

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
return resideMenu.onInterceptTouchEvent(ev) || super.dispatchTouchEvent(ev);
}


@Override
public void onClick(View view) {

if (view == itemHome){
changeFragment(new HomeFragment());
}else if (view == itemProfile){
changeFragment(new ProfileFragment());
System.out.println("profile click");
}else if (view == itemCalendar){
}else if (view == itemSettings){

Expand All @@ -91,6 +96,7 @@ public void closeMenu() {
};

private void changeFragment(Fragment targetFragment){
resideMenu.clearIgnoredViewList();
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.main_fragment, targetFragment, "fragment")
Expand Down

0 comments on commit 62ef1ef

Please sign in to comment.