📄 ac01.java
字号:
package com.misoo.ex01_04x;import android.app.Activity;import android.content.Intent;import android.graphics.Color;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.view.ViewGroup.LayoutParams;import android.widget.Button;import android.widget.LinearLayout;import android.widget.TextView;public class ac01 extends Activity implements OnClickListener { /** Called when the activity is first created. */ static final int PICKUP_REQUEST = 0; LinearLayout layout; TextView tv; Button btn, btn2; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); layout = new LinearLayout(this); LayoutParams lp = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layout.setOrientation(LinearLayout.VERTICAL); tv = new TextView(this); layout.addView(tv, lp); btn = new Button(this); btn.setText("Pickup"); btn.setTextColor(Color.RED); btn.setOnClickListener(this); layout.addView(btn, lp); btn2 = new Button(this); btn2.setText(" EXIT "); btn2.setOnClickListener(this); layout.addView(btn2, lp); setContentView(layout); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == PICKUP_REQUEST) { if (resultCode == RESULT_CANCELED) setTitle("Canceled..."); else if(resultCode == RESULT_OK) { String data_str = (String)data.getCharSequenceExtra("DataKey"); this.tv.setText("choice: " + data_str); } } } public void onClick(View v) { if (v == btn){ Intent in = new Intent(ac01.this, pickup.class); startActivityForResult(in,PICKUP_REQUEST); } if(v.equals(btn2)){ this.finish(); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -