第十三天 | |
所花时间 | 3h |
代码量 | 100行 |
博客量 | 1篇 |
所学的知识 | android studio页面的制作以及时间的添加 |
public class stud extends AppCompatActivity { ImageView addButton; private TextView dateTextView; @SuppressLint("WrongViewCast") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_stud); dateTextView = findViewById(R.id.timeTextView); // 获取当前日期 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String currentDate = sdf.format(new Date()); // 设置当前日期到日期文本视图 dateTextView.setText(currentDate); addButton = findViewById(R.id.addButton); Button studyLogButton = findViewById(R.id.studyLogButton); studyLogButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent2 = new Intent(stud.this, list.class); startActivity(intent2); } }); Button studyLogButton1 = findViewById(R.id.viewTodoButton); studyLogButton1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent3 = new Intent(stud.this, view.class); startActivity(intent3); } }); Button studyLogButton2 = findViewById(R.id.statisticsButton); studyLogButton2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent4 = new Intent(stud.this, statistics.class); startActivity(intent4); } }); addButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // 在点击时跳转到另一个页面 Intent intent = new Intent(stud.this, todo.class); startActivity(intent); } }); } }
标签:3.22,Intent,stud,Override,new,id,View From: https://www.cnblogs.com/dmx-03/p/18093244