0

誰かがこのコードで私を助けてくれれば幸いです:

1- ユーザー用の 3 つのアクティビティ English.class、France.class、Italian.class 用に 3 つの RadioButton があります アプリの起動時に既定の言語を選択します。誰かがそれを実装する方法を手伝ってもらえますか..?

public class Settings extends Activity {

private RadioGroup radioLaGroup;
private RadioButton radioLaButton;
private CheckBox chk_clear;
private Button btnDisplay;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);

addListenerOnButton();
addListenerClear();

}


 public void addListenerOnButton() {

radioLaGroup = (RadioGroup) findViewById(R.id.radioLa);
btnDisplay = (Button) findViewById(R.id.btnDisplay);

btnDisplay.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {

            // get selected radio button from radioGroup
        int selectedId = radioLaGroup.getCheckedRadioButtonId();

        // find the radiobutton by returned id
            radioLaButton = (RadioButton) findViewById(selectedId);

    }

});

}
}

前もって感謝します.....

4

2 に答える 2

0

onClick メソッド内で Switch を使用します。

@Override
public void onClick(View v) {
    Intent intent = null;
    int selectedId = radioLaGroup.getCheckedRadioButtonId();
    switch(selectedId) {
        case R.id.frenchRadio:
            intent = new Intent(this, French.class);
            break;
        case R.id.italianRadio:
            intent = new Intent(this, Italian.class);
            break;
        case R.id.englishRadio:
            intent = new Intent(this, French.class);
            break;
    }
    if(intent != null) {
        startActivity(intent);
    }   
}
于 2013-11-03T11:02:18.000 に答える
0

私は変更によって解決しました:

SharedPreferences preferences = getSharedPreferences("PREFERENCE", 0);

これに:

SharedPreferences preferences = getSharedPreferences("help", 0);

ラグナンダンさん、リプレイありがとうございます....

しかし、まだ解決していません RadioButton neeeeed ヘルプ ..... お願いします

于 2013-11-03T09:02:11.433 に答える