学校跟着潮流也开起了android的课程、学了点皮毛后、来实际操作下。写博客的目的是为了以后能再回过头看看细节方面的实现。。。。
建一个Sample01Activity,代码如下:
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.*;
- import android.content.Intent;
- import android.view.View.Listener;
- import android.widget.*;
-
- public class Sample01Activity extends Activity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- setTitle("android world"); TextView myTextView = (TextView)findViewById(R.id.myTextView);
- myTextView.setText("点击下面的按钮进入另一个界面");
- Button myButton = (Button)findViewByI(R.id.myButton);
- myButton.setText("点击此处");
- myButton.setListener(new MyButtonListener());
- }
- class MyButtonListener implements Listener{
- public void (View v){
- Intent intent = new Intent();
- intent.setClass(Sample01Activity.this, Other.class );
- Sample01Activity.this.startActivity(intent);
- }
- }
- }