我是新的開發android應用程序使用Xamarin。我正在開發一個包含許多對話框和活動的應用程序,其中一個對話框具有這樣的佈局,一個時間選擇器,兩個標記爲「取消」和「確定」的按鈕以及一個文本視圖。我想做這樣的事情,當用戶點擊「確定」按鈕時,timepicker中選擇的時間將顯示在textview上。 (或者我想提取按鈕點擊事件中的timepicker的值)需要幫助xamarin.android與時間選擇器
0
A
回答
2
這很簡單。檢查了這一點:
你Main.axml(佈局)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TimePicker
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/picker" />
<Button
android:text="OK"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnOK" />
<Button
android:text="Cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnCancel" />
<TextView
android:text="Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txt"
android:textSize="40dp" />
</LinearLayout>
和你的OnCreate()方法必須包含此:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
Button OK = FindViewById<Button>(Resource.Id.btnOK);
Button Cancel = FindViewById<Button>(Resource.Id.btnCancel);
TimePicker picker = FindViewById<TimePicker>(Resource.Id.picker);
TextView txt = FindViewById<TextView>(Resource.Id.txt);
OK.Click += (sender, e) =>
{
//getting values from TImePicker via CurrentHour/CurrentMinutes
txt.Text = String.Format("{0} : {1}",picker.CurrentHour,picker.CurrentMinute);
};
}
相關問題
- 1. 需要MySQL選擇幫助
- 2. 需要幫助選擇
- 3. jQuery on()需要選擇器幫助
- 4. 需要幫助HTML選擇選項
- 5. 需要幫助就transitionFromView:toView:持續時間:選擇:完成:
- 6. 需要與列表選擇監聽器的幫助
- 7. SQL查詢選擇幫助需要
- 8. 需要幫助的jQuery選擇
- 9. 需要MySQL選擇查詢幫助
- 10. 需要SQL選擇查詢幫助
- 11. sqlite的選擇需要幫助
- 12. 兩個選擇查詢需要幫助
- 13. 需要幫助選擇Ajax框架
- 14. 填充三重選擇幫助需要
- 15. 需要Selenium元素選擇幫助
- 16. 需要幫助建立我的選擇
- 17. 需要幫助選擇進入
- 18. 需要幫助選擇技術
- 19. 需要幫助在選擇條款
- 20. 需要幫助彙總選擇
- 21. 需要幫助mysqli PHP選擇語句
- 22. 爲選中的ListView項目需要顏色選擇器幫助
- 23. 需要幫助計算工作時間
- 24. 需要幫助學習跑步時間
- 25. 需要幫助來創建時間槽
- 26. 幫助需要與json iphone
- 27. 與需要幫助的UpdatePanel
- 28. 需要幫助與applicationDidBecomeActive
- 29. 幫助需要與drawRect:
- 30. ContentControl與DataTemplateSelector - 需要幫助
在SO,您必須證明您已經嘗試了什麼然後再問「如何去做這件事」。 –