In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to use TimePickerView in Android". In daily operation, I believe many people have doubts about how to use TimePickerView in Android. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use TimePickerView in Android". Next, please follow the editor to study!
Let's take a look at the specific effect:
First, add to the project:
Implementation 'com.contrarywind:Android-PickerView:3.2.7'
Put a button on the page and click the pop-up date selector:
@ Override protected void onCreate (@ Nullable Bundle savedInstanceState) {/ / call / / initialize the date selector showTimePicker () in the onCreate method first } / / display time public void showTimePicker () {pvTime = new TimePickerView.Builder (this, new TimePickerView.OnTimeSelectListener () {@ Override public void onTimeSelect (Date date, View v) {SimpleDateFormat format = new SimpleDateFormat ("yyyy-MM-dd"); birthday = format.format (date); tvbirthday.setText (birthday) }}). SetSubmitText ("OK") .setCancelText ("cancel") .setCancelColor (Color.BLACK) .setSubmitColor (Color.BLACK) .setSubCalSize (16) / / .isDialog (true) / / whether the dialog box style is displayed (displayed in the middle of the page) / / .isCycle (true) / / whether Loop scrolling .setType (new boolean [] {true True,true,false,false,false}) / / shows which items of "year, month, day, hour and second" .isCenterLabel (false) / / whether only the selected label text is displayed False comes with label .build () for every item. / / set the displayed date Calendar calendar = Calendar.getInstance (); try {calendar.setTime (new SimpleDateFormat ("yyyy-MM-dd"). Parse ("2020-11-20");} catch (ParseException e) {/ / e.printStackTrace () } / / it should be noted that the month starts at 0. To display October, the parameter here should be 9 / / calendar.set (1997 calendar 10); pvTime.setDate (calendar);}
Called when the button is clicked:
@ Override public void onClick (View v) {switch (v.getId ()) {case R.id.linedate: pvTime.show (); break;}} this ends the study of "how to use TimePickerView in Android", hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.