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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:12:15+00:00 2026-05-28T00:12:15+00:00

For example if i have to create custom list view about type of food,

  • 0

For example if i have to create custom list view about type of food, in each list_item consist of food type logo, food type name. If i store food type name in string resource and store picture of each food type in drawable.

1) How can i get the picture from drawable and set to List view?
2) How to get the picture that match name of food type

Thanks you in advance.

public class FoodListActivity extends ListActivity {

    private CustomListAdapter listAdapter;
    private String[] food_type_name;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.foodlistholder);

       food_type_name = getResources().getStringArray(R.array.food_name_array);


        listAdapter = new CustomListAdapter(this, R.layout.list_item_food, food_type_name);



        setListAdapter(listAdapter);


    private class CustomListAdapter extends ArrayAdapter<String>{

        private String[] items;

        public CustomListAdapter(Context context, int textViewResourceId,
                String[] items) {
            super(context, textViewResourceId, items);
            this.items = items;
        }


        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View v = convertView;
            if(v == null){
                LayoutInflater  vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.list_item_food, null);
            }

            TextView foodNameStr = (TextView)v.findViewById(R.id.food_name_txt);

            foodNameStr.setText(items[position]);
                //How to set Image view form drawable, which match the food's type name

        return v;


    }

  }

}
  • 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-28T00:12:15+00:00Added an answer on May 28, 2026 at 12:12 am

    Just like you did by setting the text, but for a ImageView.

    ImageView foodPhoto = (ImageView)v.findViewById(R.id.food_photo);
    foodPhoto.setImageDrawable(foodDrawable);
    

    You just need to create a list of drawable ids to know which drawable to use.

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

Sidebar

Related Questions

How can I create View on Linked Server db. For Example I have a
How to create jinternalframes who's action depends on each other? example suppose i have
I have a problem with the Create View in the SimpleRepository example in Subsonic
I have seen that in Cocoa I can create a custom view using drawing
I have a List of custom object, which consist of a custom list. class
I have to create a regular expression for some path conversion. Example for path
I am trying to create a generic formatter/parser combination. Example scenario: I have a
I have 9 DTD files example xhtml dtd1 xhtml dtd2 I want to create
I have taken an example straight out of the MSDN. I want to create
I have a list of custom colors that I use in all the UI

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.