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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:54:35+00:00 2026-05-26T22:54:35+00:00

currently i’m trying to get a custom spinner to work. It uses a custom

  • 0

currently i’m trying to get a custom spinner to work. It uses a custom layout and the arrayadapter of it gets filled by custom objects. now i want a icon to appear next to every object in the spinner.

so far i use code that looks like this:

    // create spinner
    logicSpinner = (Spinner) view.findViewById(R.id.logicSpinner);
    logicAdapter = new ArrayAdapter<SearchLogic>(parent, R.layout.icon_spinner_layout, R.id.typesfield, myLogics);
    logicSpinner.setAdapter(logicAdapter);

where myLogics provides a ArrayList with types of SearchLogic. The SearchLogic class looks like this

public class SearchLogic {

    private String  otherString;
    private String  localString;
    private int     imageRes;

    public SearchLogic(String otherString, String localString, int imageRes){
        this.otherString = otherString;
        this.localString = localString;
        this.imageRes = imageRes;

    }
    /*
     * let's override the toString method since thats the method a spinner object uses as default value for its entries
     */
    @Override
    public String toString(){
        return this.localString;
    }

The icon_spinner_layout looks like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/ObjectSpecificIcon"
        android:layout_width="wrap_content"
    android:layout_height="fill_parent"
        android:src="@drawable/ic_launcher"/>
    <TextView
        android:id="@+id/typesfield"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</LinearLayout>

now i’m creating a new SearchLogic object and adding it to myLogics like so:

myLogics.add(new SearchLogic("string1", "string2", R.drawable.iconXYZ));

and i would like that “ObjectSpecificIcon” is filled with the icon passed to the SearchLogic object. How to do that? is it possible to provide a “placeholder” within the layout.xml file instead of providing a hard-coded src? or any other way?

  • 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-26T22:54:36+00:00Added an answer on May 26, 2026 at 10:54 pm

    here is how its done: Method for Spinner item click listener with SimpleCursorAdapter and ViewBinder

    basicly you have to use a custom ViewBinder for the Array / CursorAdapter. See my own answer to get the final problems i had while implementing it resolved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently It just opens up the xml, but i want to get a dialog
Currently I’m trying to get the hang of a block copy with my current
Currently we have a project with a standard subversion repository layout of: ./trunk ./branches
Currently, if I want to output a SQL script for a table in my
Currently I'm trying to parse some html and return an array with the values
I want use html5's new tag to play a wav file (currently only supported
Currently my server is running of the Tomcat 5.5.26 and JDK 1.5.15. Now I
currently we have quite a chunky auditing system for objects within our application, the
Currently I have alot of information that are in several different divs. I want
Currently I'm learning C++ and I've been trying to create a simple image processing

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.