Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.gyk1;
- import android.os.Bundle;
- import android.app.Activity;
- import android.content.Intent;
- import android.view.View;
- import android.view.View.OnClickListener;
- //import android.widget.Button;
- import android.widget.TextView;
- public class MainActivity extends Activity {
- MyClickListener l = new MyClickListener();
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- TextView t1 = (TextView) findViewById(R.id.t1);
- t1.setOnClickListener(l);
- TextView t2 = (TextView) findViewById(R.id.t2);
- t2.setOnClickListener(l);
- setContentView(R.layout.activity_main);
- }
- public class MyClickListener implements OnClickListener{
- @Override
- public void onClick(View v) {
- if(v.equals(findViewById(R.id.t1))){
- Intent intent = new Intent(MainActivity.this,Activity2.class);
- startActivity(intent);
- }else if(v.equals(findViewById(R.id.t2))){
- finish();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment