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

AARRR traffic funnel model|Himalaya FM analysis report!

This article uses the AARRR traffic funnel model ...

NIO ES6 starts at RMB 180,000, with a range expected to exceed 450 kilometers

Recently, NIO disclosed in its prospectus that th...

To promote Internet products, are you still using traditional branding methods?

As we all know, the advertising industry has a hi...

Hema Fresh Product Analysis

Hema Fresh is an important part of Alibaba's ...

Baidu Ai Purchasing ranking rules are released. How to rank high?

First of all, we need to understand the ranking r...

Tik Tok Promotion: The Secret of Tik Tok’s Recommendation Algorithm!

Algorithms are an indispensable evaluation mechan...

How to write a good copy that will not be disliked by users?

Just like posting advertising copy in the circle ...

Prologue to the Kingdom of Genes: What is genetic material?

Produced by: Science Popularization China Author:...