Android 高仿【优酷】圆盘旋转菜单 的实现(2)

2. MainActivity;

import android.os.Bundle;   import android.app.Activity;   import android.view.Menu;   import android.view.View;   import android.view.View.OnClickListener;   import android.widget.ImageButton;   import android.widget.RelativeLayout;      public class MainActivity extends Activity {          private ImageButton home;       private ImageButton menu;       private RelativeLayout level2;       private RelativeLayout level3;              private boolean isLevel2Show = true;       private boolean isLevel3Show = true;          @Override       public void onCreate(Bundle savedInstanceState) {           super.onCreate(savedInstanceState);           setContentView(R.layout.activity_main);              home = (ImageButton) findViewById(R.id.home);           menu = (ImageButton) findViewById(R.id.menu);              level2 = (RelativeLayout) findViewById(R.id.level2);           level3 = (RelativeLayout) findViewById(R.id.level3);              menu.setOnClickListener(new OnClickListener() {                  @Override               public void onClick(View v) {                   if(isLevel3Show){                       //隐藏3级导航菜单                        MyAnimation.startAnimationOUT(level3, 5000);                   }else {                       //显示3级导航菜单                        MyAnimation.startAnimationIN(level3, 500);                   }                                      isLevel3Show = !isLevel3Show;               }           });              home.setOnClickListener(new OnClickListener() {                  @Override               public void onClick(View v) {                   if(!isLevel2Show){                       //显示2级导航菜单                        MyAnimation.startAnimationIN(level2, 500);                   } else {                       if(isLevel3Show){                           //隐藏3级导航菜单                            MyAnimation.startAnimationOUT(level3, 5000);                           //隐藏2级导航菜单                            MyAnimation.startAnimationOUT(level2, 500500);                           isLevel3Show = !isLevel3Show;                       }                       else {                           //隐藏2级导航菜单                            MyAnimation.startAnimationOUT(level2, 5000);                       }                   }                   isLevel2Show = !isLevel2Show;               }           });          }      }  

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/ed2d594557bb043435799a64f5d82058.html