//Program 1
import
android.widget.*; //1
import
android.view.*; //2
import
android.view.View.OnClickListener;//3
public
class MainActivity extends Activity {
Button b1; //4
@Override
protected void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1=(Button)
findViewById(R.id.button1); //5
b1.setOnClickListener(s1);
//6
}
public
OnClickListener s1=new
OnClickListener()
{
public
void onClick(View v)
{
if(v==b1)
{
Toast.makeText(getApplicationContext(), "welcome", Toast.LENGTH_SHORT).show();
}
}
};
}
No comments:
Post a Comment