开发学院手机开发Android 开发 Android Activity 中常见的控件 阅读

Android Activity 中常见的控件

 2010-09-10 01:12:00 来源:WEB开发网   
核心提示:61. }62.63. }64. }package kaier.test; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import and

61. }

62.

63. }

64. }

package kaier.test; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class Deom extends Activity { /** Called when the activity is first created. */ private Button button; private EditText editOne; private EditText editTwo; private TextView textView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //获取各个组件,并给其赋值 button=(Button)findViewById(R.id.button); editOne=(EditText)findViewById(R.id.strOne); editTwo=(EditText)findViewById(R.id.strTwo); textView=(TextView)findViewById(R.id.strCheng); button.setText(R.string.button); textView.setText(R.string.strCheng); button.setOnClickListener(new BclickListener()); } //菜单选项的添加 @Override public boolean onCreateOptionsMenu(Menu menu) { // TODO Auto-generated method stub menu.add(1, 1, 1, R.string.exit); menu.add(1,2,2,R.string.about); return super.onCreateOptionsMenu(menu); } //对菜单选项进行控制 @Override public boolean onOptionsItemSelected(MenuItem item) { // TODO Auto-generated method stub if (item.getItemId()==1){ finish(); } return super.onOptionsItemSelected(item); } class BclickListener implements OnClickListener{ @Override public void onClick(View v) { Intent intent =new Intent(); intent.putExtra("one",editOne.getText().toString()); intent.putExtra("two", editTwo.getText().toString()); intent.setClass(Deom.this, Result.class); Deom.this.startActivity(intent); } } }

Result.java

1. package kaier.test;

2.

3. import android.app.Activity;

4. import android.content.Intent;

5. import android.os.Bundle;

上一页  1 2 3 4 5 6  下一页

Tags:Android Activity 常见

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接