Note that there are some explanatory texts on larger screens.

plurals
  1. POcheckbox not working properly in android
    primarykey
    data
    text
    <p>I have made a simple checkbo[x demo program in android,in that i've put a chekbox and a button.I want is that when chekbox is pressed and button is pressed thet toast showing "i accept" else when button pressed toast generated as "i dont accept"...i have made it but problem is when i unchecked the chekbox..it shows toast directly(without clicking button);</p> <p><strong>mainActivity.java</strong></p> <pre><code>package com.example.chechboxdemo; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.Toast; public class MainActivity extends Activity { CheckBox c1; Button b; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); c1=(CheckBox)findViewById(R.id.checkBox1); b=(Button)findViewById(R.id.button1); c1.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean arg1) { // TODO Auto-generated method stub if(c1.isChecked()){ b.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "i accept", 1).show(); } }); } else{ Toast.makeText(getApplicationContext(), "i don't accept", 1).show(); } } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload