📄 ac01.java
字号:
package com.misoo.ppxx;import android.app.Activity;import android.os.Bundle;import android.view.KeyEvent;import android.widget.CheckBox;import android.widget.CompoundButton;import android.widget.LinearLayout;import android.widget.CompoundButton.OnCheckedChangeListener;public class ac01 extends Activity implements OnCheckedChangeListener { private final int WC = LinearLayout.LayoutParams.WRAP_CONTENT; private int state_var_A, state_var_B; public boolean isCube; @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); state_var_A = 0; //initial state_var_B = 0; isCube = false; goto_state_1(); } void goto_state_1() //go to state-01 { setTitle("State_1"); state_var_A = 1; LinearLayout layout_01 = new LinearLayout(this); layout_01.setOrientation(LinearLayout.VERTICAL); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(200, 250); param.leftMargin = 1; param.topMargin = 3; if(state_var_B == 0 || state_var_B == 3) isCube = false; else isCube = true; MySurfaceView sv = new MySurfaceView(this); sv.setCube(isCube); layout_01.addView(sv,param); setContentView(layout_01); } void goto_state_2() { setTitle("State_2"); state_var_A = 2; goto_state_3(); //default state } void show_layout_02() { LinearLayout.LayoutParams para; LinearLayout layout_02 = new LinearLayout(this); layout_02.setOrientation(LinearLayout.HORIZONTAL); para = new LinearLayout.LayoutParams(200, 250); para.leftMargin = 1; para.topMargin = 3; MySurfaceView sv = new MySurfaceView(this); sv.setCube(isCube); layout_02.addView(sv,para); CheckBox cx = new CheckBox(this); cx.setText("Cube"); cx.setChecked(isCube); cx.setOnCheckedChangeListener(this); para = new LinearLayout.LayoutParams(WC, WC); para.leftMargin = 30; para.topMargin = 30; layout_02.addView(cx, para); setContentView(layout_02); } void goto_state_3() { state_var_A = 2; state_var_B = 3; setTitle("State_3"); } void goto_state_4() { state_var_A = 2; state_var_B = 4; setTitle("State_4"); } @Override public boolean onKeyDown(int keyCode, KeyEvent msg) { switch(keyCode) { case KeyEvent.KEYCODE_A: if(state_var_A == 1) if(isCube) { this.show_layout_02(); goto_state_4(); } else { this.show_layout_02(); goto_state_3(); } else if(state_var_A == 2) goto_state_1(); break; } return true; } /* @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(state_var_A == 2){ if(state_var_B == 3) goto_state_4(); else if(state_var_B == 4) goto_state_3(); } } */ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(state_var_A == 2){ if(state_var_B == 3) goto_state_4(); else if(state_var_B == 4) goto_state_3(); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -