Android Studio 复选框
Android Studio Check Box
我正在寻求有关此错误的帮助:
error: incompatible types: no unique maximal instance exists for type variable T with upper bounds CheckBox,View
where T is a type-variable:
T extends View declared in method findViewById(int)
...当 运行 此代码时我得到:
public class CheckBox extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_check_box);
CheckBox checkbox1 = new CheckBox();
checkbox1 = findViewById(R.id.bx1);
}
}
您需要勾选复选框,因为返回的表单 findViewById
是通用的
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_check_box);
CheckBox checkbox1 = (Checkbox) findViewById(R.id.bx1);
}
我正在寻求有关此错误的帮助:
error: incompatible types: no unique maximal instance exists for type variable T with upper bounds CheckBox,View where T is a type-variable: T extends View declared in method findViewById(int)
...当 运行 此代码时我得到:
public class CheckBox extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_check_box);
CheckBox checkbox1 = new CheckBox();
checkbox1 = findViewById(R.id.bx1);
}
}
您需要勾选复选框,因为返回的表单 findViewById
是通用的
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_check_box);
CheckBox checkbox1 = (Checkbox) findViewById(R.id.bx1);
}