【发布时间】:2013-11-16 11:07:01
【问题描述】:
有两个编辑文本 ::
edittext timepicker 的 Onclick 应该会弹出
如何使用时间选择器在两个编辑文本中选择日期&设置日期
- 我用谷歌搜索了 timepicker
- 但我不知道如何在点击 edittext 时启动 timepicker 和 设定时间
XML::
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="3dp" >
<TextView
android:id="@+id/lunch_from_textview_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/image1"
android:layout_toRightOf="@+id/lunch_button_id"
android:gravity="center"
android:paddingLeft="30dp"
android:text="From"
android:textColor="#000000"
android:textSize="15sp" />
<EditText
android:id="@+id/from_lunch_edit_text_id"
android:layout_width="55dp"
android:layout_height="40dp" />
<TextView
android:id="@+id/lunch_to_textview_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/lunch_button_id"
android:layout_toRightOf="@+id/textView1"
android:gravity="center"
android:text="To"
android:textColor="#000000"
android:textSize="15sp" />
<requestFocus />
<EditText
android:id="@+id/to_lunch_edit_text_id"
android:layout_width="55dp"
android:layout_height="40dp"
android:ems="10" />
</LinearLayout>
BuffetOfferings_MainFragmentActivity.java
public class BuffetOfferings_MainFragmentActivity extends FragmentActivity{
Button back_button;
FragmentManager manager;
FragmentTransaction transaction;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.buffet_offerings_fragment_main_reference);
Buffet_offerings_breakfast_menu1 breakfast_fragment=new Buffet_offerings_breakfast_menu1();
Buffet_offerings_lunch_menu1 lunch_fragment=new Buffet_offerings_lunch_menu1();
Buffet_offerings_dinner_menu1 dinner_fragment=new Buffet_offerings_dinner_menu1();
manager=getSupportFragmentManager();
transaction=manager.beginTransaction();
transaction.add(R.id.BREAKFAST_LAYOUT_ID,breakfast_fragment, "breakfast_menu1_fragment");
transaction.add(R.id.LUNCH_LAYOUT_ID,lunch_fragment, "lunch_menu1_fragment");
transaction.add(R.id.DINNER_LAYOUT_ID,dinner_fragment, "dinner_menu1_fragment");
transaction.commit();
back_button=(Button) findViewById(R.id.TopNavigationBarRestaurantBuffetOfferingsBackButton);
back_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
finish();
}
});
}
}
【问题讨论】:
-
你想在哪个edittext中设置时间..??
-
对于两个编辑文本....分别:)
-
好的...所以你必须为它调用点击事件方法......并且刚刚声明了另一个静态最终 int TIME_DIALOG_ID_MY = 1 变量..
标签: android timepicker