私はこれに関する多くの投稿を読みましたが、このケースに当てはまるものは見つかりません。
タイムピッカーダイアログがあり、整数値を文字列にまとめました。この文字列をメインアクティビティに戻す必要があります。
この文字列値は、ボタンのテキストを設定するために使用されます。
誰かがこれで私を助けることができればそれは最もありがたいです。
ありがとうございました
ダイアログフラグメント
public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current time as the default values for the picker
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
// Create a new instance of TimePickerDialog and return it
return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
// Do something with the time chosen by the user
String Time =Integer.toString(hourOfDay) + " : " + Integer.toString(minute);
}
}
コード
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
Button btn = (Button) findViewById(R.id.start_time_button);
Button.setText(Time);
}