Imitate IOS Segment, search box, switch button and time selection

Imitate IOS Segment, search box, switch button and time selection

Source code introduction: My blog has a related introduction: http://blog.csdn.net/csdnfml/article/details/49589931 Recently, there are several requirements for imitating several special effects of IOS. I have never done it before, so I imitated their results and integrated them to share with you.

Source code effect:

Source code snippet:

  1. /** Two buttons toggle */  
  2. private   void initView() {
  3. mSegmentView = (SegmentView) findViewById(R.id.segment_view);
  4. mSegmentView.setSegmentText( "Hello" , 0 );
  5. mSegmentView.setSegmentText( "I'm OK" , 1 );
  6. mSegmentView.setOnSegmentViewClickListener( new SegmentView.onSegmentViewClickListener() {
  7. @Override  
  8. public   void onSegmentViewClick(View v, int position) {
  9. switch (position) {
  10. case   0 :
  11. Toast.makeText(mContext, "Hello" , Toast.LENGTH_SHORT).show();
  12. break ;
  13. case   1 :
  14. Toast.makeText(mContext, "I'm good" , Toast.LENGTH_SHORT).show();
  15. break ;
  16. default :
  17. break ;
  18. }
  19. }
  20. });
  21. }
  22.   
  23. /** Three button switches */  
  24. private   void initViewThree() {
  25. mSegmentViewThree = (SegmentViewThree) findViewById(R.id.segment_view_three);
  26. mSegmentViewThree.setSegmentText( "Hello" , 0 );
  27. mSegmentViewThree.setSegmentText( "I'm OK" , 1 );
  28. mSegmentViewThree.setSegmentText( "He is good" , 2 );
  29. mSegmentViewThree.setOnSegmentViewClickListener( new SegmentViewThree.onSegmentViewClickListener() {
  30. @Override  
  31. public   void onSegmentViewClick(View v, int position) {
  32. switch (position) {
  33. case   0 :
  34. Toast.makeText(mContext, "Hello" , Toast.LENGTH_SHORT).show();
  35. break ;
  36. case   1 :
  37. Toast.makeText(mContext, "I'm good" , Toast.LENGTH_SHORT).show();
  38. break ;
  39. case   2 :
  40. Toast.makeText(mContext, "He is good" , Toast.LENGTH_SHORT).show();
  41. break ;
  42. default :
  43. break ;
  44. }
  45. }
  46. });
  47. }

Download address: http://download..com/data/2115239

<<:  Add tags to pictures

>>:  Third-party login

Recommend

A guide to entering and starting broadcasting on Douyin Box!

My friends, will you use Douyin box instead of Ta...

7 common traits of effective programmers

Introduction: To be a great programmer, you need ...

What should I do if a gas tank catches fire?

On the morning of June 24, an explosion occurred ...

How to improve product user retention?

Rethinking retention Retention is an often mentio...

Live streaming methods and strategies

The women's clothing category with a customer...

VR will enter an 18-month battle period. How should startups respond?

February 19th news, if you are one of the virtual...

The Windows 8 ban only involves 30 computers, but it represents an attitude

Recently, a statement in the “Notice on Supplement...

Substantial changes will happen to social media in 2017!

How will social media evolve? It is a topic that ...

Analysis of the competition between Kuaiying and Jianying

“Competitive product analysis is one of the essen...

Momo promotion: Momo product analysis report!

Momo is a pan-entertainment and pan-social platfo...

Sony PS VR head: The so-called VR killer app does not exist

Every time a new platform emerges in the technolo...

Gigya: 2017 Consumer Attitudes towards Privacy and Security Report

199IT original compilation There are still many t...