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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:23:24+00:00 2026-06-05T12:23:24+00:00

can someone explain me what i am doing wrong/what i have to do? I

  • 0

can someone explain me what i am doing wrong/what i have to do?

I have a listview that is getting its information from a json array. But it is a custom listview, with 5 images and some text on each row. Each image has a /drawable/image_selector with different images according to enabled/disabled. I am able to dynamically set the text for each row, using hashmap and a ListAdapter. But i am trying to do the same with the images and i am not able to do it. is using a custom adapter the right choice? and if so how? i have not understood from the examples how to use them.

Thanks

here is the code for the given activity:
public class DisponiveisActivity extends ListActivity {
;
//para os icones do layout

private ProgressDialog pDialog;

//Object of class JSON Parser
JSONParser jsonParser = new JSONParser();
ArrayList<HashMap<String, String>> disponiveislist;


public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list);


    disponiveislist = new ArrayList<HashMap<String, String>>();
    new Loaddisp().execute();

}
//Background ASYNC task to load

class Loaddisp extends AsyncTask<String, String, String>{
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(DisponiveisActivity.this);
        pDialog.setMessage("Carregando");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();
    }



    protected String doInBackground(String... args) {


                String nome = l.getString("NOME");
                String preco = l.getString("PRECO");
                String cfotografia = l.getString("COMFOTOGRAFIA");
                String cdados = l.getString("COMDADOS");
                String copiniao = l.getString("COMOPINIAO");

                String cdeslocacao = l.getString("COMDESLOCACAO");



                String distancia = l.getString("DISTANCIA");

                //create new HASHMAP                    
                HashMap<String,String> map = new HashMap<String,String>();
                map.put("NOME", nome);  
                map.put("PRECO", preco);
                map.put("DISTANCIA", distancia);
                map.put("COMOPINIAO", copiniao);
                map.put("COMDADOS", cdados);
                map.put("COMFOTOGRAFIA", cfotografia);
                //------------------------------


                disponiveislist.add(map);

            }




    @Override
    protected void onPostExecute(String file_url) {
        // TODO Auto-generated method stub

        pDialog.dismiss();
        runOnUiThread(new Runnable() {
            public void run() {
                /**
                 * Updating parsed JSON data into ListView
                 * */



                    Log.d("PP",disponiveislist.toString());
                ListAdapter adapter = new SimpleAdapter(DisponiveisActivity.this, disponiveislist, R.layout.listrow,new String[]{"NOME","PRECO","DISTANCIA"}, new int[]{R.id.mission_name, R.id.preco, R.id.cdistancia});




                setListAdapter(adapter);


            }
        });
    }



    }

}

  • 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-05T12:23:26+00:00Added an answer on June 5, 2026 at 12:23 pm

    Great example I just found on Google:
    In this case, you have only one image, I really hope you will understand how to duplicate the code for 5 pictures a row.

    public class ItemsList extends ListActivity {
    
    private ItemsAdapter adapter;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            setContentView(R.layout.items_list);
    
            this.adapter = new ItemsAdapter(this, R.layout.items_list_item, ItemManager.getLoadedItems());
            setListAdapter(this.adapter);
    }
    
    private class ItemsAdapter extends ArrayAdapter<Item> {
    
            private Item[] items;
    
            public ItemsAdapter(Context context, int textViewResourceId, Item[] 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.items_list_item, null);
                    }
    
                    Item it = items[position];
                    if (it != null) {
                            ImageView iv = (ImageView) v.findViewById(R.id.list_item_image);
                            if (iv != null) {
                                    iv.setImageDrawable(it.getImage());
                            }
                    }
    
                    return v;
            }
    }
    
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
            this.adapter.getItem(position).click(this.getApplicationContext());
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone explain to me what the bolded portions of this code are doing?
Can someone explain how New works with the With keyword in this example from
Can someone explain the difference between these two, the first one is taken from
I can't figure out what am I doing wrong here, I have there are
I can't figure out if I'm doing anything wrong here, hopefully someone here can
I'm hoping someone can either tell me what I'm doing wrong correct my flawed
Can someone explain it succinctly? Can it be used with non-Silverlight clients?
Can someone explain to me this odd thing: When in python shell I type
Can someone explain how can I add custom font, css classes styles to Contribute?
Can someone explain why this doesn't work? int main() { float* x; float a,

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.