You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.5 KiB
44 lines
1.5 KiB
package com.example.game2048;
|
|
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.widget.Button;
|
|
import android.widget.TextView;
|
|
import android.widget.Toast;
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
public class MenuActivity extends AppCompatActivity {
|
|
public TextView hy;
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.menu);//调用xml中activity_main。
|
|
Button b1 = (Button) this.findViewById(R.id.bt_ks);
|
|
b1.setOnClickListener(new ButtonListenerI());
|
|
Button b2 = (Button) this.findViewById(R.id.bt_st);
|
|
b2.setOnClickListener(new ButtonListenerII());
|
|
|
|
Intent intent = getIntent();
|
|
String hy = intent.getStringExtra("Name");
|
|
TextView textView = (TextView)findViewById(R.id.hy);
|
|
textView.setText("Hello, "+hy);
|
|
}
|
|
private class ButtonListenerI implements View.OnClickListener{
|
|
@Override
|
|
public void onClick(View v){
|
|
Intent intent=new Intent(MenuActivity.this,GameActivity.class);//设置切换对应activity
|
|
startActivity(intent);//开始切换
|
|
}
|
|
}
|
|
|
|
private class ButtonListenerII implements View.OnClickListener{
|
|
@Override
|
|
public void onClick(View v){
|
|
Intent intent=new Intent(MenuActivity.this,GameActivityII.class);//设置切换对应activity
|
|
startActivity(intent);//开始切换
|
|
}
|
|
}
|
|
}
|