event handler java

Download Event Handler Java

If you can't read please download the document

Upload: waseem

Post on 18-Sep-2015

217 views

Category:

Documents


3 download

DESCRIPTION

hjjhjhjhjhj

TRANSCRIPT

package com.example.waseemjaved.eventhandler;import android.app.Activity;import android.support.v7.app.ActionBarActivity;import android.os.Bundle;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.widget.Button;import android.widget.ImageView;import android.widget.Toast;public class EventHandlerActivity extends Activity implements View.OnClickListener { Button b1, b2; int a; String s; ImageView im; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_event_handler); b1=(Button)findViewById(R.id.btn1); b1.setOnClickListener(this); b2=(Button)findViewById(R.id.btn2); b2.setOnClickListener(this); im=(ImageView)findViewById(R.id.im); } @Override public void onClick(View v) { a=v.getId(); if (a==R.id.btn1) { Toast t = Toast.makeText(this, "You Have Clicked", Toast.LENGTH_SHORT); t.show(); im.setBackgroundResource(R.drawable.smiley1); } else { Toast t = Toast.makeText(this, " Are You Have Clicked", Toast.LENGTH_SHORT); t.show(); s=b1.getText().toString(); b1.setText(s); } }}