小编And*_*rey的帖子

17
推荐指数
2
解决办法
10万
查看次数

Android单选按钮选择

我用单选按钮进行选择.当我把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(); 
        }
    });
Run Code Online (Sandbox Code Playgroud)

有我的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
Run Code Online (Sandbox Code Playgroud)

...

android selection radio-button

0
推荐指数
1
解决办法
94
查看次数

标签 统计

android ×2

download ×1

internal ×1

radio-button ×1

selection ×1

storage ×1