Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9084325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:58:21+00:00 2026-06-16T20:58:21+00:00

I am trying to make a custom style for android spinner, however there are

  • 0

I am trying to make a custom style for android spinner, however there are several problems.
I have noticed in many examples, they pass array to getCustomView method. I am wondering whether I can pass a list instead of an array.

Second problem is why they have declared variable and initialized in class variable scope?
They have declared arrays like this.

String []data1={"Brainbitz:java","Brainbitz:Android","Brainbitz:Embedded Systems","Brainbitz:PHP"};

in class variable scope. But when I try to do for the list I get an error. why?

Third is,

If we can pass list to getCustomView how do I do that? Here is the link to the tutorial tutorial

I am considering this source code.

 public View getCustomView(int position, View convertView, ViewGroup parent) {

            LayoutInflater inflater=getLayoutInflater();
            View row=inflater.inflate(R.layout.spinner, parent, false);
            TextView label=(TextView)row.findViewById(R.id.textView1);
            label.setText(list3.get(position));

//            TextView sub=(TextView)row.findViewById(R.id.textView2);
//            sub.setText(data2[position]);
//
//            ImageView icon=(ImageView)row.findViewById(R.id.imageView1);
//            icon.setImageResource(images[position]);

            return row;
            }

In above code I don’t know the syntax to pass position to list3 list type reference.

Please be kind enough to explain this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:58:22+00:00Added an answer on June 16, 2026 at 8:58 pm

    First of All,

    You are using default ArrayAdapter Class..

    new ArrayAdapter<String>();
    

    Which Uses String class for data bind. If you want to make an ArrayAdapter with a ArrayList or List you have to make a Custom Adapter by extending ArrayAdapter<Custom_Class> or BaseAdapter.

    The ArrayAdapter class can handle any Java object as input. It maps the data of this input to a TextView in the layout.

    ArrayAdapter uses the toString() method of the data input object to determine the String which should be displayed.

    Look at How to use ArrayAdapter<myClass> and this Tutorial

    Update:

    public class MyAdapter extends ArrayAdapter<String>
    {
      private List<String> listString = new ArrayList<String>();
    
      public MyAdapter(Context context, int textViewResourceId,
                            List<String> objects) {
      super(context, textViewResourceId, objects);
      // TODO Auto-generated constructor stub
      listString  = objects;
      }
    
      public View getCustomView(int position, View convertView, ViewGroup parent) {
    
       LayoutInflater inflater=getLayoutInflater();
       View row=inflater.inflate(R.layout.spinner, parent, false);
       TextView label=(TextView)row.findViewById(R.id.textView1);
       label.setText(listString.get(position)); // How to use listString
       .
       .
       .
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to make custom radio buttons using HTML, CSS, and JavaScript.
I'm trying to make a custom infowindow. Version = 2. I have added my
I am trying to make a custom style for a TabItem Header. I got
I am starting out on Android and trying to make a custom ListView layout.
I'm trying to make custom Notifications in Android, following that link : http://developer.android.com/guide/topics/ui/notifiers/notifications.html This
I'm trying to make a custom control in Silverlight have the same functionality as
I'm trying to make a custom titlebar for my first Android application. While I
I have an imageView and I am basically trying to make a thermometer style
I am trying to make Custom RelativeLayout which can scale and scroll. Right now
Trying to make a custom :confirm message for a rails form that returns data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.