Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.myapplication0710;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.TextView;
- import androidx.appcompat.app.AppCompatActivity;
- public class MainActivity extends AppCompatActivity {
- int count;
- TextView tv;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- count=0;
- tv = findViewById(R.id.tvCount);
- }
- public void handleClick(View v) {
- count++;
- tv.setText(tv.getText().toString()+1);
- if (count > 10) {
- nextActivity(null);
- count=0;
- tv.setText(count+"");
- }
- }
- public void handleResetClick(View view) {
- count=0;
- tv.setText(count+"");
- }
- public void nextActivity(View view) {
- Intent intent;
- intent = new Intent(this,MainActivity2.class);
- intent.putExtra("COUNT_VALUE",count);
- startActivity(intent);
- //finish();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement