使用輪我使用了Android輪的時間選擇和獲得的值如下設置時間的Android
private void SetTime(Context activity, int hour, int minute) {
LayoutInflater inf = LayoutInflater.from(activity);
// layout of alert box contains
View view = inf.inflate(R.layout.wheel, null);
final WheelView hours = (WheelView) view.findViewById(R.id.hours);
hours.setViewAdapter(new NumericWheelAdapter(activity, 0, 23,"%02d"));
hours.setCyclic(true);
hours.setCurrentItem(expiryHour);
Log.d(TAG, "for expiryHour123456 ---> " + expiryHour);
final WheelView mins = (WheelView) view.findViewById(R.id.minutes);
mins.setViewAdapter(new Mywheel(activity, 0, 59,"%02d"));
mins.setCyclic(true);
mins.setCurrentItem(expiryMinute);
Log.d(TAG, "for expiryMinute123456 ---> " + expiryMinute);
new AlertDialog.Builder(activity)
.setMessage("Set Time For Post To AutoDelete")
.setView(view)
.setPositiveButton("Set",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
expiryHour = hours.getCurrentItem();
Log.d(TAG, "for expiryHour ---> " + expiryHour);
if(mins.getCurrentItem() > 0){
expiryMinute = mins.getCurrentItem() + 4;
Log.d(TAG, "for expiryMinute ---> " + expiryMinute);
}else{
expiryMinute = mins.getCurrentItem();
}
}
});
}
當IAM設置我得到正確的價值觀的時候,但是,一旦設定的時間和再次如果我想改變時間,分鐘值顯示錯誤。例如,首先我將它設置爲2:10,然後當我打開它的顯示2:14時,我想要改變現在不應該發生的事情。任何幫助表示讚賞。
是有原因...... 00後,我顯示05,跳過01,02,03,04 – teekib 2013-03-12 10:27:43
如果是這樣的話,你可以把條件一樣,如果(mins.getCurrentItem()== 0) {period_Minute = mins.getCurrentItem()+ 4; Log.d(TAG,「for expiryMinute --->」+ expiryMinute); } else { expiryMinute = mins.getCurrentItem(); } – Kameswari 2013-03-12 10:37:54
我的代碼正在工作..現在我在設置值時出現問題..值iam正確但輪子中的數字正在改變 – teekib 2013-03-12 10:46:23