Different Android selectors are easy to use and address date and time are easy to use !, Android Selector

Source: Internet
Author: User

Different Android selectors are easy to use and address date and time are easy to use !, Android Selector

Preface

Picker is used in many cases in Android development, such as selecting the address, date, and time.

 

Native Picker and iOS-like Picker both move up and down or left to a fixed area to choose options:

The number of displays is small. If the current option is far away from the required option, it will be slide many times;

Sliding is difficult to control. It is annoying to slide slowly back to the opposite direction if you are not careful.

 

The GridPicker in ZBLibrary displays multiple rows and multiple columns on each page, greatly increasing the number of displays. The sliding option is changed to click selection, which greatly improves the operation precision.

 

I. Native Picker

 

Problem:

1.The number of options displayed in the address and time selector is small.Switch only one by one, with low efficiency.

2. to select a year for the date selector, You need to click the text of the year at the top of the page. It is not easy for your fingers to reach, and few options are displayed;

Select the month and click the left arrow or the right arrow to slide. Only one switch is allowed.Low Efficiency.

 

 

Ii. iOS-like Picker

 

Problem:

1.The number of displayed options is small..

2. The option can only be switched one by one.

3. RequiredSlide up or down to the specified box,Difficult to control. 

 

 

Iii. ZBLibrary GridPicker

The Gif image below looks like a card, but the mobile phone actually runs smoothly.

 

All operations are on the lower half of the screen,OperationEasy;

Multiple rows and multiple columns are displayed on each page, which greatly increases the display quantity;

Change the sliding selection to click selection, which greatly improves the operation accuracy.

 

ZBLibrary GridPickerSolved all the above problems perfectly!

 

 

 

How to Use ZBLibraryGridPicker

1. Download, import, and dependency on ZBLibrary

Click the link on the right to view http://my.oschina.net/u/2437072/blog/665241

 

2. Open the corresponding Activity and pass the value

Take the date selector DatePickerWindow as an example:

 

You can open and pass the value in this way.

toActivity(DatePickerWindow.createIntent(context, new int[]{1971, 0, 1}            , TimeUtil.getDateDetail(System.currentTimeMillis())), 1000, false);

ToActivity is the method in BaseActivity in ZBLibrary. It can be changed to startActivityForResult.

 

3. Receive returned results in onActivityResult

@ Override public void onActivityResult (int requestCode, int resultCode, Intent data) {super. onActivityResult (requestCode, resultCode, data); if (resultCode! = RESULT_ OK) {return;} switch (requestCode) {case 1000: if (data! = Null) {ArrayList <Integer> list = data. getIntegerArrayListExtra (DatePickerWindow. RESULT_DATE_DETAIL_LIST); if (list! = Null & list. size ()> = 3) {show1_toast ("date selected" + list. get (0) + "-" + (list. get (1) + 1) + "-" + list. get (2) ;}} break; default: break ;}}

 

Okay.

If you are too reluctant to perform the steps 2-3, copy, paste, and rename DemoMainActivity. java in ZBLibrary, and change the code!

 

 

In fact, the address, date, and time selectors in ZBLibrary use GridPickerView to control the display and operation,

You can also use GridPickerView to implement selector for other purposes.

 

 

ZBLibrary-Android quick development framework

(Welcome to Star and Fork)

Https://github.com/TommyLemon/Android-ZBLibrary

Download trial

ZBLibraryDemoApp.apk

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.