安卓页面跳转

移动开发 waitig 523℃ 百度已收录 0评论
package com.example.administrator.demo2;

import android.support.v7.app.AppCompatActivity;
import android.content.Intent;
import android.view.View;//注意view的大小写
import android.view.View.OnClickListener;
import android.os.Bundle;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    private Button button4 = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        button4 = (Button)findViewById(R.id.button4);
        button4.setText( "跳转" );
        button4.setOnClickListener(new MyButtonListener());
    }
    class MyButtonListener implements OnClickListener{
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent();
            intent.setClass(MainActivity.this, Main2Activity.class);
            MainActivity.this.startActivity(intent);
        }
    }


    }

本文由【waitig】发表在等英博客
本文固定链接:安卓页面跳转
欢迎关注本站官方公众号,每日都有干货分享!
等英博客官方公众号
点赞 (0)分享 (0)