How to check if android checkbox is checked within its onClick method (declared in XML)?

后端 未结 5 1500
终归单人心
终归单人心 2020-12-05 03:41

I have a checkbox in android which has the following XML:



        
5条回答
  •  孤城傲影
    2020-12-05 04:32

    This will do the trick:

      public void itemClicked(View v) {
        if (((CheckBox) v).isChecked()) {
            Toast.makeText(MyAndroidAppActivity.this,
               "Checked", Toast.LENGTH_LONG).show();
        }
      }
    

提交回复
热议问题