Android基础知识学习——界面转换

MainActivity:

package com.example.xinwen;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {
    private Button bt;
    @Override
   
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
        bt=(Button)findViewById(R.id.denglu);
       
    bt.setOnClickListener(new OnClickListener(){

  @Override
  public void onClick(View arg0) {
   // TODO Auto-generated method stub
   
   Intent in=new Intent (MainActivity.this,FirstActivity.class);
   startActivity(in);
      System.out.println("登陆成功");
  }});
 }


 @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
   
}

 

 

 

FirstActivity:

package com.example.xinwen;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class FirstActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_first);
 }

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.first, menu);
  return true;
 }

}

Android基础知识学习——界面转换_第1张图片Android基础知识学习——界面转换_第2张图片

你可能感兴趣的:(android)