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

  • Home
  • SEARCH
  • 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 8166781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:59:54+00:00 2026-06-06T19:59:54+00:00

Im using a BaseAdapter and passing to it a List of objects that have

  • 0

Im using a BaseAdapter and passing to it a List of objects that have their own data sets. In each row of the listview Id like an image, description, ect. of each object. When I use the BaseAdapter as I have it set now I dont get any errors and Ive checked over and over in the debugger and logcat that my List of objects are valid and not null. But for some reason the list builds with the correct number of objects but not one of the ImageViews, TextViews, or anything else takes on any of the data. The only thing in each row is the same default data I use in the xml layout for the list row. Its like the call to each View’s set method is either being ignored for some reason or the content for the view is being passed to another context onscreen or something wacky. Anyway heres my BaseAdapter class:

 class MaItemAdapter extends BaseAdapter{
        List<Ma> mas = null;
        Context cntx = null;
        //LayoutInflater myInflater;
        int itemPosition =0;
        ViewHolder holder;

        public MarkItemAdapter(Activity cntx,List<Ma> mas){
            super();
            this.mas = mas;
            this.cntx = cntx;
            //myInflater = LayoutInflater.from(cntx);

        }

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return mas.size();
        }

        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return mas.get(position);
        }

        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            itemPosition = position;
            RelativeLayout rl = null;
            Mark ma = mas.get(itemPosition);
            if (convertView==null) {
                rl = (RelativeLayout) LayoutInflater.from(cntx).inflate(
                        R.layout.ma_row_item, parent, false);
                holder = new ViewHolder();
                try{
                holder.description = (TextView) rl.findViewById(R.id.ma_description);
                holder.distance = (TextView) rl.findViewById(R.id.ma_distance);
                holder.ma_image = (ImageView) rl.findViewById(R.id.ma_image);
                holder.view_ma = (ImageButton) rl.findViewById(R.id.view_ma);
                holder.rate_ma = (RatingBar) rl.findViewById(R.id.rate_ma);
                holder.description.setText(ma.title);
                holder.distance.setText(ma.getDistanceString());
                holder.view_ma.setOnClickListener(new OnClickListener(){

                @Override
                public void onClick(View arg0) {
                    //dostuff
                }

            });
            if(ma.textImg!=null &&
                    !ma.textImg.isRecycled()){
            holder.ma_image.setImageBitmap(ma.textImg);
            }else{
                holder.ma_image.setImageResource(R.raw.skyma);
            }}catch(NullPointerException e){}
            }else{
                rl = (RelativeLayout) convertView;
            }


        //add logic for rating bar

            return rl;
        }


    }

//convenience class to create views 
    private class ViewHolder{
        ImageView ma_image;
        TextView description;
        TextView distance;
        ImageButton view_ma;
        RatingBar rate_ma;

        public ViewHolder(){
            ma_image = new ImageView(getApplicationContext());
            description = new TextView(getApplicationContext());
            distance = new TextView(getApplicationContext());
            view_ma = new ImageButton(getApplicationContext());
            rate_ma = new RatingBar(getApplicationContext());
        }
    }

}

Ive run through a few tutorials and they work fine but when I use this set up in my own app its a no go. Some help in the right direction would be awesome. One other thing I should mention is that if I push on the rating bar i see the same rating pop up every four or five rows.
Any help would be much appreciated.

  • 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-06T19:59:57+00:00Added an answer on June 6, 2026 at 7:59 pm

    Try this in your getView method…this is how my custom adapters are setup.

    itemPosition = position;
    View v = convertView;
    Mark ma = mas.get(itemPosition);
    
    if (v == null) {
        LayoutInflater inflater = (LayoutInflater) cntx
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = inflater.inflate(R.layout.ma_row_item, null);
        holder = new ViewHolder();
    }
    
    holder.description = (TextView) v.findViewById(R.id.ma_description);
    holder.distance = (TextView) v.findViewById(R.id.ma_distance);
    holder.ma_image = (ImageView) v.findViewById(R.id.ma_image);
    holder.view_ma = (ImageButton) v.findViewById(R.id.view_ma);
    holder.rate_ma = (RatingBar) v.findViewById(R.id.rate_ma);
    holder.description.setText(ma.title);
    holder.distance.setText(ma.getDistanceString());
    holder.view_ma.setOnClickListener(new OnClickListener(){
    
        @Override
        public void onClick(View arg0) {
            //dostuff
        }
    
    });
    
    if(ma.textImg!=null && !ma.textImg.isRecycled()) {
        holder.ma_image.setImageBitmap(ma.textImg);
    } else {
        holder.ma_image.setImageResource(R.raw.skyma);
    }
    

    If that doesn’t work, I could also suggest just initializing your individual views from within the getView method body instead of in ViewHolder. Something like:

    TextView description = (TextView) v.findViewById(R.id.ma_description);
    description.setText(ma.title);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When my list view using a BaseAdapter goes off the screen, each row no
HI Guyz i have created a sectioned custom listview using baseadapter its working fine
I've got a ListView that is populated using a custom BaseAdapter (MyBaseAdapter) : public
I've got a ListView with a custom BaseAdapter. The list items contain CheckBoxes that
I have a listview that uses a customadapter based on the baseadapter. The listview
I'm using a listview with my own implementation of baseadapter. Before adding the main
I have a listview with each row containing some text and a delete button.
I need to populate ListView with List of objects returned from my Dao object.
I'm using isEnabled in my BaseAdapter of ListView and controlling which rows can be
I have facing problem in listview i am getting data from server and after

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.