package com.example.myapplication;
import static android.view.View.*;
import static com.example.myapplication.R.*;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.example.myapplication.R.id;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(layout.activity_main);
TextView tv = findViewById(id.tv);
tv.setTextSize(30);
tv.setTextColor(Color.MAGENTA);
tv.setText("你好,希儿");
Button button = findViewById(id.button);
Button button1 = findViewById(id.button1);
button.setTextColor(0xff00ff00);
button.setBackgroundColor(Color.YELLOW);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(MainActivity.this, MainActivity2.class);
startActivity(intent);
}
});
button1.setTextColor(0xff00ff00);
button1.setBackgroundColor(Color.GREEN);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v1) {
Intent intent = new Intent();
intent.setClass(MainActivity.this, Mainphoto1.class);
startActivity(intent);
}
});
}
}
标签:总结,tv,button1,intent,3.24,import,android,Intent From: https://www.cnblogs.com/XiMenXve/p/17253208.html