Android单选按钮选择

 爱生活爱花落_485 发布于 2023-01-31 16:33

我用单选按钮进行选择.当我把setOnCheckedChangeListener放到应用程序时.请帮忙.

public class SetReseau extends Activity{

public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    RadioGroup radioReseau = (RadioGroup) findViewById(R.id.radioReseau);
    setContentView(R.layout.set_reseau_setting);

    radioReseau.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup group, int checkedId) { 
            RadioButton radioButton = (RadioButton) findViewById(checkedId);
            Toast.makeText(getApplicationContext(), "" + radioButton.getText(), Toast.LENGTH_LONG).show(); 
        }
    });

有我的logcat

E/AndroidRuntime(18822): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime(18822): java.lang.RuntimeException: Unable to start activity     ComponentInfo{com.sms/com.sms.SettingsActivity}: 
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sms/com.sms.SetReseau}: java.lang.NullPointerException

...

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有