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

Build a user growth activity matrix in 3 steps

The online education industry has achieved rapid ...

12 Practical Ways to Prevent Your App from Becoming a Zombie

Are you familiar with the concept of "zombie...

Girl, why do you want to program?

As a girl, you can get a pair of blingbling nails...

How to promote user sharing and dissemination?

For internet dogs, it is easy to organize an even...

The Three Kingdoms’ annual drama: Lost on Journey: Xu Jiong!

Mixed Knowledge Specialized in treating misunders...

What did Xiaomi do to make Indians obsessed with "grabbing" Xiaomi?

Last year, Lei Jun, the founder of Xiaomi, announ...