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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:14:57+00:00 2026-05-30T16:14:57+00:00

I have 10 graphic needs to display in my ListView and I create a

  • 0

I have 10 graphic needs to display in my ListView

and I create a class like this

public class LayoutAdapterObj {
 public String addString;
 public ImageView leftImage;
 public String backgroundImageName;
 public LayoutAdapterObj(String addString,ImageView leftImageName,String backgroundImageName){
     this.addString = addString;
     this.leftImage = leftImageName;
     this.backgroundImageName = backgroundImageName;
 }

and when I create a LayoutAdaptor object

I do this

    aArray.add(new LayoutAdapterObj("1",new ImageView(null, null, R.drawable.frame1),"R.drawable.layout"));
    aArray.add(new LayoutAdapterObj("2",new ImageView(null, null, R.drawable.frame2),"R.drawable.layout"));
    LayoutListAdapter m_adapter;
    m_adapter = new LayoutListAdapter(this, R.layout.topbarlayout, aArray);

after that…. in my adapter class, i do this

        public View getView(int position, View convertView, ViewGroup parent) {
                View v = convertView;
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                        v = vi.inflate(R.layout.layout1, null);
                }
                LayoutAdapterObj o = items.get(position);
                if (o != null) {
                        TextView addText = (TextView) v.findViewById(R.id.addtext);                     
                        ImageView leftImage=(ImageView)v.findViewById(R.id.layoutframe);
                        if(!o.backgroundImageName.equals(""))
                        {

                        }
                        if(addText!=null)
                        {
                            addText.setText(o.addString);
                        }

the wrong message is like this

java.lang.IllegalStateException: Could not execute method of the activity

if(leftImage != null)
{
    leftImage= o.leftImage;
}
  • 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-30T16:14:59+00:00Added an answer on May 30, 2026 at 4:14 pm

    see this…example…`

       class UserListAdapter extends ArrayAdapter<String> 
        {
    
    
    
            @Override
            public int getCount() {
                // TODO Auto-generated method stub
                int temp;
                if(SharedVariables.is_traffic_search_ON_flag){
                    temp=search_cases_trafficTicketsList.size();
                }else{
                    temp=search_cases_criminalTicketsList.size();
                }
                return temp;
            }
    
            Activity context;
    
            public UserListAdapter(Activity context) {
                super(context, 0);
    
                Log.d("hh","sgbdfjfdgfk");
    
                this.context = context;
            }
    
             class ViewHolder {
    
                 RelativeLayout rl2;
                 ImageView genderimage;
                 TextView ticketcounttt;
                 TextView name;
                 TextView city;
                 TextView added_date;
            }
    
            @SuppressWarnings("unused")
            public View getView(final int position, View convertView, ViewGroup parent){//here we inflating the layout "R.layout.cars_row"
                ViewHolder holder;
                View rowView = convertView;
                if (rowView == null) {
    
                    LayoutInflater inflater = context.getLayoutInflater();
    
                    if(SharedVariables.is_traffic_search_ON_flag)rowView = inflater.inflate(R.layout.traffic_row, null, true);
                    else rowView = inflater.inflate(R.layout.criminal_row, null, true);
    
                    holder = new ViewHolder();
    
    
                    holder.rl2=(RelativeLayout) rowView.findViewById(R.id.rl2); 
    
                    try{
                    holder.genderimage=(ImageView) rowView.findViewById(R.id.genderimage);
                    }catch (Exception e) {
                        e.printStackTrace();
                        // TODO: handle exception
                    }
                    holder.ticketcounttt=(TextView) rowView.findViewById(R.id.ticketcounttt);
                    holder.name=(TextView) rowView.findViewById(R.id.textView1);
                    holder.city=(TextView) rowView.findViewById(R.id.textView2);
                    holder.added_date=(TextView) rowView.findViewById(R.id.textView333);
    
                    //Traffic cases...
                    if(SharedVariables.is_traffic_search_ON_flag)
                    {
    
                        if(search_cases_trafficTicketsList.get(position).CaseID!=0)holder.rl2.setBackgroundResource(R.drawable.green_color1); //Pink color...
                        else  holder.rl2.setBackgroundResource(R.drawable.pink_color); //Green color...
    
            if(search_cases_trafficTicketsList.get(position).Sex.equals("M"))holder.genderimage.setBackgroundResource(R.drawable.man);
                        else holder.genderimage.setBackgroundResource(R.drawable.woman);
            holder.ticketcounttt.setTypeface(SharedVariables.font);
            holder.name.setTypeface(SharedVariables.font);
            holder.city.setTypeface(SharedVariables.font);
            holder.added_date.setTypeface(SharedVariables.font);
            holder.name.setText(search_cases_trafficTicketsList.get(position).FirstName+" "+search_cases_trafficTicketsList.get(position).LastName);
            holder.city.setText(search_cases_trafficTicketsList.get(position).City+" City"+"("+search_cases_trafficTicketsList.get(position).ZIP+")");
    
                        try{
    
                            String s[]=search_cases_trafficTicketsList.get(position).ViolationDate.split("/");
    
                            String month=SharedVariables.convertFromNumberToMonth(Integer.parseInt(s[0]));
                            String day=s[1];
    
                            String year=s[2].substring(0,4);
    
                        holder.added_date.setText("Added: "+Integer.parseInt(day)+" "+month+" "+year);  
                        }catch (Exception e) {
                            e.printStackTrace();
                            // TODO: handle exception
                        }           
    
                        try{
                            holder.ticketcounttt.setText(""+search_cases_trafficTicketsList.get(position).Violations.split(",").length);
                        }catch (Exception e) {
                            e.printStackTrace();
                            // TODO: handle exception
                        }       
    
                    }
    
                    //Criminal casess...
                    else{
    
                        if(search_cases_criminalTicketsList.get(position).CaseID!=0)holder.rl2.setBackgroundResource(R.drawable.green_color1); //Pink color...
                        else  holder.rl2.setBackgroundResource(R.drawable.pink_color); //Green color...
    
                holder.ticketcounttt.setTypeface(SharedVariables.font);
            holder.name.setTypeface(SharedVariables.font);
            holder.city.setTypeface(SharedVariables.font);
            holder.added_date.setTypeface(SharedVariables.font);
            holder.name.setText(search_cases_criminalTicketsList.get(position).FirstName+" "+search_cases_criminalTicketsList.get(position).LastName);
            holder.city.setText(search_cases_criminalTicketsList.get(position).City+" City");
    
                        try{
    
                            String s[]=search_cases_criminalTicketsList.get(position).ViolationDate.split("/");
    
                            String month=SharedVariables.convertFromNumberToMonth(Integer.parseInt(s[0]));
                            String day=s[1];
    
                            String year=s[2].substring(0,4);
    
                        holder.added_date.setText("Added: "+Integer.parseInt(day)+" "+month+" "+year);  
                        }catch (Exception e) {
                            e.printStackTrace();
                            // TODO: handle exception
                        }           
    
                        try{
                            holder.ticketcounttt.setText(""+search_cases_criminalTicketsList.get(position).Violations.split(",").length);
                        }catch (Exception e) {
                            e.printStackTrace();
                            // TODO: handle exception
                        }       
    
                    }
    
    
                    rowView.setTag(holder);                 
    
                }
                else
                {
                    holder = (ViewHolder) rowView.getTag();
                }
    
                return rowView;
    
            }
    
            @Override
            public long getItemId(int position) {
                // TODO Auto-generated method stub
                return position;
            }
    
    
        }`
    

    call your adapter like this

    UserListAdapter a=new UserListAdapter();
    yurlistview.setAdapter(a);

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

Sidebar

Related Questions

I have an RGB565 byte array which I display on my Canvas like this:
I really like to have some graphic on my startup/login screen when starting my
I have a tiled background graphic with a header and footer part. Something like
I have one class that needs to grab an attribute that is set in
I have an image to display via an ImageView element. Based on user input
I want to simulate stroking a carpet, so you would have a graphic of
I have a png graphic that is put in the web page using raphael
I am having dependency troubles. I have two classes: Graphic and Image . Each
I have a small (6x9) graphic that I want to draw on a CButton.
I have the following directory structure: . .. ./Graphic/ ./Graphic/SymbolXLib There are several other

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.