已经在Android任何API提供的日期,时间,从用户(startActivityForResult)输入? [英] Has Android any API to provide Date-time as input from user (startActivityForResult)?

查看:394
本文介绍了已经在Android任何API提供的日期,时间,从用户(startActivityForResult)输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找的API,提供由用户定义的日期时间信息。我在过去使用联系人列表如下:

I'm looking for API that provide Date-time info defined by user. I used in the past Contact List like:

Intent intent = new Intent(Intent.ACTION_PICK);
    intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
    ((Activity) mContext).startActivityForResult(intent, LauncherUI.RESULT_GOT_CONTACT_INFO);

onActivityResult

Uri contactData = intent.getData();
    //Cursor cursor =  managedQuery(contactData, null, null, null, null);
    Cursor cursor =  cr.query(contactData, null, null, null, null);
    cursor.moveToFirst();
    String name = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
    String id = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts._ID));

我可以提取的名称电话的Gmail 的。

现在我的目标是与格式YYYY-MM-DD HH做同样的日期,时间:MM:SS。 是这样的:

Now my aim to do the same for Date-time with format YYYY-MM-DD hh:mm:ss. Something like:

我不希望由我自己来实现它,因为此功能存在(仅在情况下,如果没有API)

I don't want to implement it by myself since this feature exists (only in case if no API)

任何想法?

推荐答案

是的,Android已经内置的日期和时间选择器对话框,看到的有关详细信息,这文章(它使用的片段,但你可以用简单的 DatePickerDialog 和放大器; TimePickerDialog )。

Yes, Android has built-in date and time picker dialogs, see this article for details (it uses fragments but you can use simply DatePickerDialog & TimePickerDialog).

您也可以使用其他的开源库,阴凉的数据采集器:

You can also use other open source libraries with a cool data picker:

  • https://code.google.com/p/android-dateslider/
  • https://code.google.com/p/android-wheel/
  • https://code.google.com/p/scroll-picker-view-for-android/
  • ...

(采用Android UI模式的应用程序的https: //play.google.com/store/apps/details?id=com.groidify.uipatterns&hl=es 中找到像这些库)

(Use Android UI patterns app https://play.google.com/store/apps/details?id=com.groidify.uipatterns&hl=es to find libraries like these)

这篇关于已经在Android任何API提供的日期,时间,从用户(startActivityForResult)输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆