Monday, 5 August 2013

Customn DropDown Spinner in Android

Hello everyone!

Here’s another cool Android tutorial that talks about creating your own DropDown Spinner widget in Android. From the Android developers page, a Spinner is a view that displays one child at a time and lets the user pick among them.Our Default Spinner provide Drop Down above 4.0 version. In this tutorial you will create a customized Spinner like Gmail app using library project. This is also work in 4.0 below version. You can create spinner like this:




Using this Library you can set following features:

Methods:

  • setItemTextColor(int color) - Set the item text font color in drop down.
  • setItemBackgroundColor(int color) - Set the item background color in drop down.
  • setItemTextSize (int size) - Set the item text size
  • setVisibleItemNo (int no) - Set the height of DropDown spinner equal to number of visible rows
  • addItem(String item) - Add the single string item in spinner
  • addItem(String item, int resId) - Add the single string item and image in spinner
  • setItems(String[] arr) - Set the string array in spinner
  • setItems(String[] arr, int[] ico) - Set the string array & image array in list. size of string array and image array required equal.
  • getSelectedPosition() - Return the position of currently selected item within the adapter's data set.
  • setSelectedPosition(int selectedPosition)- Set the currently selected item.

Listener : 

  setOnItemClickListener

  setOnItemSelectedListener


 You can set custom spinner control in xml like this:

<com.anky.dropdownspinner.DropdownSpinner
            android:id="@+id/my_spinner1" 
            android:layout_width="40dp" 
            android:layout_height="40dp" 
            android:background="@drawable/standard_menu_button_bg" 
            android:text="" />
You can set property like this:

private DropdownSpinner spinner1  = (DropdownSpinner) findViewById(R.id.my_spinner1); 

private String[] strings = { "Inter Milan", "AC Mila", "Manchesterb",
            "Barcelona", "Valencia", "Juventus" }; 

spinner1.setItems(strings);

spinner1.addItem("Test1"); 

spinner1.addItem("Test2");  

spinner1.addItem("Test3",R.drawable.ic_menu_moreoverflow_normal_holo_light);
 
spinner1.addItem("", R.drawable.ic_menu_moreoverflow_normal_holo_light);  

spinner1.addItem("Test4", -1); 

spinner1.setVisibleItemNo(5);  

spinner1.setItemTextColor(Color.BLACK); 

spinner1.setItemPadding(18, 15, 18, 15); 

spinner1.setItemTextSize(20); 

spinner1.setItemBackgroundColor(Color.WHITE);  

spinner1.setOnItemClickListener(new OnItemClickListener()  { @Override public void onItemClick(AdapterView paramAdapterView,  View paramView, int paramInt, long paramLong) 
{ // TODO Auto-generated method stub

 clickItem = "Center: Click item:" + paramInt; txtClick.setText(clickItem); 

 }  
});

 You can download source code from here.

43 comments:

  1. Replies
    1. Great Article android based projects

      Java Training in Chennai Project Center in Chennai Java Training in Chennai projects for cse The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training Project Centers in Chennai

      Delete
  2. it's very useful blog fr me thank you for sharing the information....

    Financial industry regulation|FCA compliance|FCA assistance

    ReplyDelete
  3. Wiztech Automation is the Leading Best IEEE Final year project Centre in Chennai and the final year students are provided complete guidance and support in their final year projects. The IEEE projects in Chennai that Wiztech Automation offers guidance and support for include complete range of system domains – such as PLC projects, embedded projects, VLSI projects, software projects, IT projects, Civil projects. Students looking for specific projects pertaining to departments of ECE, EEE, E&I, Mechanical, Mechatronics, bio-medical, IT, Computer, Civil projects in B.E, M.E, B.Tech, M.Tech, B.SC., and M.Sc Electronics, could also get turnkey solutions at Wiztech Automation Solutions to turn out successful project outcomes and models. Since the students at Wiztech Automation gain thorough theoretical and practical knowledge and skills as they pursue their final year projects and develop 2015 and 2016 Latest IEEE Projects portraying them well.

    Final year projects in chennai
    Mechanical projects in chennai
    ece projects in chennai
    Final year eee projects in chennai
    VLSI project center in chennai
    Industrial projects in chennai
    Fianl year CSE projects in chennai

    ReplyDelete
  4. WIZTECH Automation, Anna Nagar, Chennai, has earned reputation offering the best automation training in Chennai in the field of industrial automation. Flexible timings, hands-on-experience, 100% practical. The candidates are given enhanced job oriented practical training in all major brands of PLCs (AB, Keyence, ABB, GE-FANUC, OMRON, DELTA, SIEMENS, MITSUBISHI, SCHNEIDER, and MESSUNG)

    PLC training in chennai
    Automation training in chennai
    Best plc training in chennai
    PLC SCADA training in chennai
    Process automation training in chennai
    Final year eee projects in chennai
    VLSI training in chennai

    ReplyDelete
  5. Embedded system training: Wiztech Automation Provides Excellent training in embedded system training in Chennai - IEEE Projects - Mechanical projects in Chennai Wiztech provide 100% practical training, Individual focus, Free Accommodation, Placement for top companies. The study also includes standard microcontrollers such as Intel 8051, PIC, AVR, ARM, ARMCotex, Arduino etc.

    Embedded system training in chennai
    Embedded Course training in chennai
    Matlab training in chennai
    Android training in chennai
    LabVIEW training in chennai
    Arduino training in chennai
    Robotics training in chennai
    Oracle training in chennai
    Final year projects in chennai
    Mechanical projects in chennai
    ece projects in chennai

    ReplyDelete
  6. Thank you for the info. It sounds pretty user friendly. I guess I’ll pick one up for fun. thank u

    Google App Integration Chennai

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.android development course fees in chennai | android app development training in chennai

    ReplyDelete
  9. Nice blog..! I really loved reading through this article... Thanks for sharing such an amazing post with us and keep blogging...
    Feels free to get amazing update regarding SSC 2018 and south results SSLC 2018

    ReplyDelete
  10. To get the information regarding SSLC results 2018 SSLC Result Please go through this link


    We will get the Karnataka SSLC Results on instantKarnataka SSLC ResultBy just clicking this link


    Very nice to here the information of Kerala SSLC Results are availableKerala SSLC ResultOn your fingertip


    Entire Tamil SSLC Results are ready on your screenTamilnadu SSLC Result Please click on this link

    ReplyDelete
  11. Complete information regarding the PUC Results available onpuc resultPlease click this link


    More details information details of Karnataka PUC result 20182nd puc result 2018 Just go through this


    Nice to hear the Karnataka Result date is available on this link puc result date 2018Simply on your screen


    The complete timetable of Karnataka PUC 2018 is puc time table 2018. Please take a note & start preparing for the exam

    ReplyDelete
  12. We will get all information regarding the Kerala SSLC results 2018kerala sslc resultsPlease click on this link

    ReplyDelete
  13. We will get complete information of Tamilnadu HSC Results 2018tamilnadu hsc results 2018Just click on this link

    ReplyDelete
  14. We will get complete information of Tamilnadu SSLC Results 2018tamilnadu sslc results 2018Just click on this link

    ReplyDelete
  15. This is nice to hear that we will get the complete details of SSLC results 2018 of Kerala statekerala sslc results 2018by just clicking on this link

    ReplyDelete
  16. We will get complete and detailed information of Kerala Plus Two Results 2018Kerala Plus Two Results 2018On a simple on this link

    ReplyDelete
  17. We will get complete and detailed information of Kerala DHSC Results 2018Kerala DHSC Results 2018On a simple on this link

    ReplyDelete
  18. تعد شركة تركيب اثاث ايكيا بالرياض هي الشركة الرائده والاولي في كافة الاثاث من تركيب وفك ونقل وتخزين وكافة الاعمال المتعلقة بالاثاث في الرياض وكافة المناطق والمحافظات بالمملكة العربية السعودية، وقد تصدرت شركة خبراء المملكة لتكون الأولى في مجال فك ونقل وتركيب الأثاث المنزلي وايضا فك وتركيب الستائر بالرياض وهي تتميز عن باقي شركات الرياض نظرا لما تقدمة من خدمات بشكل احترافي كما انها تتميز عن غيرها بكفاءة الفنيين والامتخصصين في مجال تركيب الاثاث فلا داعي لكثرة البحث فلديك خبراء المملكة فهم فعلا خبراء ومتميزون في جميع خدماتهم المقدمة
    شركة تركيب اثاث ايكيا بالرياض
    فني تركيب اثاث ايكيا بالرياض
    شركة تركيب ستائر بالرياض
    عامل تركيب ستائر بالرياض
    شركة تركيب غرف نوم بالرياض
    فني تركيب غرف نوم بالرياض
    شركة تركيب باركية بالرياض
    شركة تركيب عفش بالرياض
    ما يميز شركة تركيب نقل وتركيب اثاث بالرياض
    - تعد شركة تركيب اثاث ايكيا من الشركات المفضلة لكثير من العملاء فهم من منحوها الصدارة والتميز لتميز الخدمات المقدمة لهم وهي الاولي في تركيب الاثاث لزيادة خبراتها الكبيرة لسنوات.
    تتميز ايضا شركة خبراء المملكة بكبر فرق العمل المتخصصة والمدربة بمهاره وتقنية عالية كما اننا ندعم صفوفنا بصفة مستمرة من العمال والموظفين والفنيين الأكفاء والمهرة كما انها Jستقبل العمالة الفليبنية

    ReplyDelete
  19. Nice blog ..! I really loved reading through this article.. Thanks for sharing such a amazing post with us and keep blogging...
    phonegap services in hyderabad

    ReplyDelete
  20. Very nice blog. Very informative. Limra Technosys is leading mobile app development company in Mumbai

    ReplyDelete
  21. This is good piece of writing and pleasant urging commented
    here, I am really enjoying by these.
    kajal hot

    ReplyDelete
  22. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
    Best Devops Training in pune
    Microsoft azure training in Bangalore
    Power bi training in Chennai

    ReplyDelete
  23. Get Industrial Automation in robotics training by experienced faculty and Experts from Industry.
    Contact us +91-99534 89987, +91-97112 87737

    ReplyDelete
  24. I was recommended this web site by means of my cousin.
    I am now not certain whether this post is written through him as nobody else recognise such precise about my difficulty. You're amazing! Thank you!

    selenium training in Chennai
    selenium training in Tambaram
    selenium training in Velachery
    selenium training in Omr
    selenium training in Annanagar


    After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience.
    Thank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in

    ReplyDelete
  25. You blog post is just completely quality and informative. Many new facts and information which I have not heard about before. Keep sharing more blog posts.
    Python Online training
    python Course institute in Chennai
    Python Course institute in Bangalore

    ReplyDelete
  26. Informative post.i learn many new things from your post it will help in my Mobile Application development company in Nagpur

    ReplyDelete
  27. Very Informative and helpful blog. prolifiquetech is leading android development company in mumbai

    ReplyDelete
  28. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post I would like to read this
    Digital Marketing Company in mumbai
    Digital Marketing agency in Mumbai

    ReplyDelete
  29. Nice work. Thank you for sharing the information.
    moviebox for pc


    ReplyDelete
  30. Thanks for sharing
    Unicsol is a Custom Software Development Company in Hyderabad that provides value-added software services by turning bytes into business by our deligent team

    ReplyDelete
  31. This is a very useful professional article. I’ll make sure to bookmark it and come back to learn extra of your useful info.
    Software Company
    Software Development Company in India
    Web Application Development
    Mobile Application Development
    ux/ui design services
    Thanks for the post
    Regards
    Siva

    ReplyDelete
  32. Nice post,

    Altorum Leren, a leading IT, Services Company, specializes in Software Application Development, Cloud Computing, UX/UI, Full Stack Development, IoT, Artificial Intelligence, Blockchain, DevOps, Front End Web Development, Back End Web Development, Mobile App Development and more. https://www.altorumleren.com/

    ReplyDelete
  33. Astrum InfoTech Agency is the Best Digital Marketing Company in Delhi, They help to generate the profit and visitors traffic on website. If you are looking for grow the online visibility of your business then please contact us. We Offer Best Digital Marketing Service like SEO Service, SMO Service, PPC Service, Facebook Marketing Services, Email marketing service, graphic design services, website designing service and website development service etc. https://www.astruminfotech.com/

    ReplyDelete
  34. Business Management coursework writing service learners have an advantage of hiring the best business research writing service that is familiar with business term paper writing services for their Business Essay Writing Services.

    ReplyDelete