import android.view.View;
import
android.view.View.OnClickListener;
import android.widget.*;
public class MainActivity extends
Activity {
CheckBox c1,c2,c3;
Button b1;
@Override
protected
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
c1=(CheckBox)
findViewById(R.id.checkBox1);
c2=(CheckBox)
findViewById(R.id.checkBox2);
c3=(CheckBox)
findViewById(R.id.checkBox3);
b1=(Button) findViewById(R.id.button1);
b1.setOnClickListener(L1);
}
public OnClickListener L1=new
OnClickListener()
{
public void onClick(View v) {
String
h1="",h2="",h3="",h4;
if(v==b1)
{
if(c1.isChecked()==true)
h1=c1.getText().toString();
if(c2.isChecked()==true)
h2=c2.getText().toString();
if(c3.isChecked()==true)
h3=c3.getText().toString();
h4=h1 +" "+h2 +"
"+h3;
Toast.makeText(getBaseContext(),h4,Toast.LENGTH_LONG).show();
}
}
}; }
No comments:
Post a Comment