主界面代码
package com.example.weather;
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 tokyo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tokyo=(Button)findViewById(R.id.wtky);
tokyo.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent in=new Intent(MainActivity.this,SecActivity.class);
startActivity(in);
}
});
}
@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;
}
}
第二个界面
package com.example.weather;
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 SecActivity extends Activity {
private Button more;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sec);
more=(Button)findViewById(R.id.morebutton);
more.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent in=new Intent(SecActivity.this,ThiActivity.class);
startActivity(in);
}});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.sec, menu);
return true;
}
}
第三界面:
package com.example.weather;
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 ThiActivity extends Activity {
private Button morei;
private Button history;
private Button game;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_thi);
morei=(Button)findViewById(R.id.more);
history=(Button)findViewById(R.id.hiswea);
game=(Button)findViewById(R.id.gbutton);
morei.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent in=new Intent(ThiActivity.this,MoreActivity.class);
startActivity(in);
}});//morei.set
history.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent in2=new Intent(ThiActivity.this,HisActivity.class);
startActivity(in2);
}});//history.set
game.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent in3=new Intent(ThiActivity.this,GameActivity.class);
startActivity(in3);
}});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.thi, menu);
return true;
}
}