当前位置: 代码迷 >> Android >> 关于checkbox的使用有关问题
  详细解决方案

关于checkbox的使用有关问题

热度:20   发布时间:2016-05-01 17:58:44.0
关于checkbox的使用问题!
先上代码:
Java code
TextView labelView;CheckBox checkBox;labelView = (TextView)findViewById(R.id.label);        checkBox = (CheckBox)findViewById(R.id.block);        if(checkBox==null)System.out.println("checkBox为空!");        if(labelView==null)System.out.println("labelView空!");

如上一个TextView和一个CheckView的使用,发现checkview那句有打印……为什么check一直是空的?

------解决方案--------------------
layout里缺少id,看仔细了

<CheckBox
android="@+id/block"

->
<CheckBox
android:id="@+id/block"

  相关解决方案