2017-06-13 54 views

回答

0

只是試試這個

所以這樣定義mSelectedTime私人字符串;

final TextView time = (TextView) mView.findViewById(R.id.tv); 
TimePicker timePicker = (TimePicker) mView.findViewById(R.id.dp); 

timePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() { 
    @Override 
    public void onTimeChanged(TimePicker view, int hourOfDay, int minute) { 
     mSelectedTime = hourOfDay + " " + ":" + " " +minute; 
    } 
}); 

,然後在你的聽衆:

set_time.setOnClickListener(new View.OnClickListener() { 
    @Override 
    public void onClick(View v) { 
     time.setText(mSelectedTime) 
} 
+0

點是「setOnTimeChangedListener」而不是「setOnClickListener」 – Meikiem

+0

它是不會改變聽者 –

+0

後甚至工作,爲什麼你寫的onClick監聽器裏監聽器? – Meikiem

相關問題