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 3991332
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:36:11+00:00 2026-05-20T06:36:11+00:00

i am using spinner in some application in spinner item list array this text

  • 0

i am using spinner in some application in spinner item list array this text replaced in drawable images how can its implemented

personalinformation = (Spinner) findViewById(R.id.SpinnerCategory);
ArrayAdapter<?> adapterDefaultpersonal = ArrayAdapter.createFromResource(Animals.this, R.array.Animalinformation, android.R.layout.simple_spinner_item);

adapterDefaultpersonal.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
personalinformation.setAdapter(adapterDefaultpersonal); 

How can the R.array.Animalinformation array list items replaced in drawable images be implemented?

  • 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-05-20T06:36:11+00:00Added an answer on May 20, 2026 at 6:36 am

    Yes it is look at the code below..
    array of data

    //stores the image database icons 
     private static Integer[] imageIconDatabase = { R.drawable.ball, R.drawable.catmouse,   R.drawable.cube, R.drawable.fresh, R.drawable.guitar, R.drawable.orange, R.drawable.teapot };
    
    //stores the image database names 
     private String[] imageNameDatabase = { "ball", "catmouse", "cube", "fresh", "guitar", "orange", "teapot" };
    

    creating List of hashmaps

    private void initializeImageList() {
    // TODO Auto-generated method stub 
    ArrayList<HashMap<String, Object>> spinnerList = new ArrayList<HashMap<String,Object>>();
    for (int i = 0; i < imageNameDatabase.length; i++) {
        HashMap map = new HashMap();
        map.put("Name", imageNameDatabase[i]);         
        map.put("Icon", imageIconDatabase[i]);         
        spinnerList.add(map);     
        }     
    ImageView imageView = new ImageView(this);     
    imageView.setBackgroundResource((spinnerList.get(0).get("Icon"));     
    spinnerList.get(0).get("Name"); 
    }
    
    // assigning spinner to adapter
    
    public void createAddDialog() { // TODO
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.list_editoradd_dialog);
    
        Spinner spin = (Spinner) findViewById(R.id.spinnerAddImageList);
        CustomSpinnerAdapter adapter = new CustomSpinnerAdapter(this, spinnerData, R.layout.spinner_view, new String[] { "Name", "Icon" }, new int[] { R.id.imageNameSpinner, R.id.imageIconSpinner });
        spin.setAdapter(adapter);
    }
    

    the adapter used above is as given below..

    class CustomSpinnerAdapter extends SimpleAdapter {
    
    LayoutInflater mInflater;
    private List<? extends Map<String, ?>> dataRecieved;
    
    public CustomSpinnerAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) {
        super(context, data, resource, from, to);
        dataRecieved = data;
        mInflater = LayoutInflater.from(context);
    }
    
    @SuppressWarnings("unchecked") 
    public View getView(int position, View convertView, ViewGroup parent) 
    {     
        if (convertView == null) { 
            convertView = mInflater.inflate(R.layout.spinner_view,null);
            } 
    HashMap<String, Object> data = (HashMap<String, Object>) getItem(position);    
    ((TextView) convertView.findViewById(R.id.imageNameSpinner)).setText((String) dataRecieved.get(position).get("Name"));
    ((ImageView) convertView.findViewById(R.id.imageIconSpinner)).setBackgroundResource(dataRecieved.get(position).get("Icon")));
    return convertView; 
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a selection for some items using a spinner widget. At the moment
I don't understand why I'm getting this error. I'm using AsyncTask to run some
I am using Spinner control in my application and my Code is Spinner s1=new
When is using a spinner object appropriate, rather than using a standard text entry
In my Application i am using Spinner which contain 1 to 60 items from
I made one application that using the spinner in it. in my application client
I have a problem. I upload some images from HDD to the website using
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters

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.