确定触发新框架的按钮

时间:2017-12-13 12:00:21

标签: java android

以下是我的代码

startBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showTimePickerDialog(view);
        }
    });

endBtn.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        showTimePickerDialog(view);
    }
});


public void showTimePickerDialog(View v) {
    DialogFragment newFragment = new TimePickerFragment();
    newFragment.show(getFragmentManager(), "timePicker");
}

@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    String time = String.format("%02d", hourOfDay) + ":" + String.format("%02d", minute);
    Log.d("DTAG", "Time Selected:" + time);
    //How to know here what button triggered the new fragment
}

如何在不在函数外部设置新值的情况下知道button触发了操作的内容?与startBtnClicked=true;

一样

0 个答案:

没有答案