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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:02:26+00:00 2026-05-20T12:02:26+00:00

Hey there, i have one question.. i try to write an android app with

  • 0

Hey there,
i have one question..

i try to write an android app with java.

i have a hashmaplist(1), saved in a list(2).
to show the list(2) entrys(those, who saved in hashmap(1)), i use a ListAdapter object.

everything works fine, except of the following:
one of the entrys, saved in the hashmaplist(1), is “country”, like ‘at’, ‘de’, ‘gb’, …
now i want to change a pics’ source, that was created on the layout, depends on the country entry.

here some code..

save entrys and show it with a ListAdapter object:

for (int i = 0; i < itemArray.length(); ++i) {
JSONObject rec = itemArray.getJSONObject(i);

//save entrys in hashmap
map = new HashMap<String, String>();
map.put("name", rec.getString("name"));
map.put("country", rec.getString("country"));


//save hashmap entry in list
mylist.add(map);
}

ListAdapter mSchedule = new SimpleAdapter(this, mylist, R.layout.listitem,
                new String[] {"name"}, new int[] {R.id.area});

listview.setAdapter(mSchedule);

Now the Layout XML:

<LinearLayout 
    android:id="@+id/linearLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <ImageView 
        android:id="@+id/imageView10" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/be">
    </ImageView>

    <TextView 
        android:id="@+id/area" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </TextView>

</LinearLayout>

Any ideas?

  • 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-20T12:02:26+00:00Added an answer on May 20, 2026 at 12:02 pm

    you have to create your own view binder like

    class CustomViewBinder extends SimplerAdapter.ViewBinder
    {
                @Override
        public boolean setViewValue(View view, Object data,
                String textRepresentation) {
            int id=view.getId();
                String country=(String)data; 
                    switch(id)
                    {
                      case R.id.country:
                                if(country.equals("us")
                                    setYourImage();
                       .....
    
                }
            }
    }
    

    and in your activity
    use your simpleAdapter as

            SimplerAdapter sa=new SimpleAdapter(this, mylist, R.layout.listitem,
                    new String[] {"name","country"}, new int[] {R.id.area,r.id.country});
            sa.setViewBinder(new CustomViewBinder());
    

    Hope this will help u

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

Sidebar

Related Questions

Hey guys, one more quick question for any experts out there. I have a
Hey guys I have one more question lol. I am using a script that
hey there, just practising and I had a question. I have a program (source
Hey guys, quick question. I have a table of messages. There are two types
Hey guys quick question, I currently have an insert statement $query= INSERT into new_mail
Hey folks, I have a question which feels stupid but I can't quite say
Hey guys, quick question, I have an id that is applied multiple times on
Hey, I have a question regarding multithreading. First off, how many instances of DispatcherServlet
Hey guys, I have a form and there are 4 buttons possible for the
Hey all, kind of new at Kohana and I have a quick question. I

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.