⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ac01.java

📁 基于ANdroid平台的高欢堂书籍的对应源代码 非常有用
💻 JAVA
字号:
package com.misoo.ppxx;import android.app.Activity;import android.content.Context;import android.os.Bundle;import android.view.KeyEvent;import android.view.LayoutInflater;import android.view.View;import android.view.View.OnClickListener;import android.widget.AdapterView;import android.widget.ArrayAdapter;import android.widget.Button;import android.widget.LinearLayout;import android.widget.ListView;import android.widget.AdapterView.OnItemClickListener;public class ac01 extends Activity implements OnClickListener, OnItemClickListener {	private final int WC = LinearLayout.LayoutParams.WRAP_CONTENT; 	private GraphicView gv = null;	private LinearLayout current_layout = null;	public int state_var_A = 0;  //initial	    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);        state_var_A = 0;        current_layout = null;    	gv = new GraphicView(this);      	goto_state_1();     }        @Override    public boolean onKeyDown(int keyCode, KeyEvent msg) {       setTitle("");       switch(keyCode) {    	   case KeyEvent.KEYCODE_A:    		   if(state_var_A == 1) 	               this.goto_state_2();        		    break;       }	    return true;	 }         void state_entry_action(){    	if(current_layout != null)    		current_layout.removeAllViewsInLayout();    }            void goto_state_1(){    	state_var_A = 1;    	this.state_entry_action();    	LinearLayout layout_01 = new LinearLayout(this);    	//--------------------------------------    	current_layout = layout_01;    	//--------------------------------------        layout_01.setOrientation(LinearLayout.VERTICAL);        LinearLayout.LayoutParams param =          	new LinearLayout.LayoutParams(150, 200);        param.leftMargin = 1;        param.topMargin = 3;        layout_01.addView(gv,param);        setContentView(layout_01);    }        void goto_state_2()  //go to state-02     {    	state_var_A = 2;    	this.state_entry_action();    	LinearLayout.LayoutParams para;    	LinearLayout layout = new LinearLayout(this);    	//--------------------------------------    	current_layout = layout;    	//--------------------------------------        layout.setOrientation(LinearLayout.VERTICAL);        para = new LinearLayout.LayoutParams(150, 200);        para.leftMargin = 1;        para.topMargin = 3;        layout.addView(gv,para);                LayoutInflater inflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);        LinearLayout in_yz_layout = (LinearLayout)inflate.inflate(R.layout.yz, null);        Button y_btn = (Button)in_yz_layout.findViewById(R.id.y_btn);         Button z_btn = (Button)in_yz_layout.findViewById(R.id.z_btn);         y_btn.setId(101);        y_btn.setOnClickListener(this);        z_btn.setId(102);        z_btn.setOnClickListener(this);                para = new LinearLayout.LayoutParams(WC, WC);        para.leftMargin = 5;         para.topMargin = 15;        layout.addView(in_yz_layout, para);        setContentView(layout);    }        void goto_state_3()  //go to state-02     {    	state_var_A = 3;    	this.state_entry_action(); //remove gv    	LinearLayout.LayoutParams para;    	LinearLayout layout_03 = new LinearLayout(this);    	//--------------------------------------    	current_layout = layout_03;    	//--------------------------------------        layout_03.setOrientation(LinearLayout.HORIZONTAL);        para = new LinearLayout.LayoutParams(150, 200);        para.leftMargin = 1;        para.topMargin = 3;        layout_03.addView(gv,para);                ListView lv = new ListView(this);        lv.setBackgroundResource(R.drawable.x_brown);        String items[] = {"To 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -