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

The nine-square grid thinking method of APP in the application market!

The boss is going crazy because there is no promo...

How to deal with muscle soreness after exercise?

Exercise is the cure for everything. Exercise is ...

Hongxing Erke Marketing Revelation

So far, there are two best cases of social market...

Brand marketing promotion, 6 common psychological effects!

Contemporary people often present some strange co...

Internet + The next hot spot in the film and television industry

In the era of mobile Internet, film and televisio...

How to achieve O&M automation and fault self-healing in the gaming industry

This article is the on-site dry goods of WOT2016 ...