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

Google launches VR portable scene-based immersive games, which are closer to us

Whether it is a sci-fi movie with lifelike shots ...

What is the lowest price per gram of good Cordyceps sinensis?

As a precious tonic medicine, Cordyceps sinensis ...

Who in your circle of friends do you most want to “blacklist”?

WeChat has become a network platform for people to...

Was it hot in the summer in ancient times? How did the ancients beat the heat?

The Fushan County Chronicles recorded the extreme...

Baidu Tieba traffic diversion tips!

Our topic today is mainly to share with you our t...

How much is the price of Guiyang second-hand car mini program agent?

How much does it cost to be an agent for Guiyang’...

Forbes columnist: Why I said Xiaomi wants to acquire Xunlei

[[138837]] Yesterday, Xunlei CEO Zou Shenglong pu...