0
我使用單選按鈕進行選擇。 當我把setOnCheckedChangeListener的應用程序crach。 請幫忙。Android單選按鈕選擇
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
...
非常感謝。這行得通。我看到了錯誤。謝謝 – Andrey