快速問題。我將如何將使用意向的單選按鈕值傳遞給其他活動?我是否也需要使用分享偏好來保存價值?將意念單選按鈕的值傳遞給其他活動?
我想要做這樣的事情「,當用戶選擇的單選按鈕(例如:紅色,藍色,綠色,黃色)和所有的TextView的顏色將在所有的活動來改變
public class Text_Colour extends Activity implements RadioGroup.OnCheckedChangeListener {
RadioButton rb1, rb2, rb3, rb4;
TextView tv2;
RadioGroup rg1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.colours);
tv2 = (TextView)findViewById(R.id.textview2);
rb1 = (RadioButton) findViewById(R.id.radioButton1);
rb2 = (RadioButton) findViewById(R.id.radioButton2);
rb3 = (RadioButton) findViewById(R.id.radioButton3);
rb4 = (RadioButton) findViewById(R.id.radioButton4);
rg1 = (RadioGroup) findViewById(R.id.radiogroup1);
rg1.setOnCheckedChangeListener(this);
}
public void onCheckedChanged(RadioGroup rg1, int r) {
// TODO Auto-generated method stub
if (r==rb1.getId()) {
tv2.setTextColor(Color.RED);
}
if (r==rb2.getId()) {
tv2.setTextColor(Color.YELLOW);
}
if (r==rb3.getId()) {
tv2.setTextColor(Color.GREEN);
}
if (r==rb4.getId()) {
tv2.setTextColor(Color.BLUE);
}
else {
tv2.setTextColor(Color.BLACK);
}
}
}
。 。感謝您的時間