我正在創建新的應用程序,這個應用程序是懷孕,我想選擇一個日期,我有最後一個日期和截止日期,但我想選擇使用單選按鈕並選擇。 請幫幫我 謝謝。如何使用單選按鈕選擇任何人的日期
這裏是我的代碼:
radioGroup_date = (RadioGroup) findViewById(R.id.radio_Date);
radioGroup_date.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
int selectedId = radioGroup_date.getCheckedRadioButtonId();//new
radioButton_date = (RadioButton) findViewById(selectedId);//new
String text = radioButton_date.getText().toString();//new
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();//new
}
});
final Calendar c = Calendar.getInstance();
year = c.get(Calendar.YEAR);
month = c.get(Calendar.MONTH);
day = c.get(Calendar.DAY_OF_MONTH);
editText_calander.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//DateDialog();
showDialog(DATE_PICKER_ID);
}
});
button_Submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dob = editText_calander.getText().toString();
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString("dob", dob);
editor.commit();
Intent intent = new Intent(getApplicationContext(), SecondActivity.class);
Bundle b = new Bundle();
// int selectedId = radioGroup_date.getCheckedRadioButtonId();
// radioButton_date = (RadioButton) findViewById(selectedId);
b.putString("baby_name", editText_baby_name.getText().toString());
b.putString("mother_name", editText_mother_name.getText().toString());
intent.putExtras(b);
startActivity(intent);
}
});
你可否透露具體 – Anil
是的,我要選擇從任何一個日期單選按鈕1.最後日期2.截止日期,如果用戶選擇最後日期而不是添加40周並顯示截止日期另一個活動,並且如果用戶想選擇直接截止日期比顯示另一個活動 –
'但我想選擇使用單選按鈕,並選擇'它是完全不清楚你想要什麼。 –