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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:11:26+00:00 2026-05-21T09:11:26+00:00

here is the code get an error arrayadapter – you must supply a resource

  • 0

here is the code get an error arrayadapter – you must supply a resource id for a textview

public class lay extends Activity
{
public class MyCustomAdapter extends ArrayAdapter<new_class> 
{

    private ArrayList<new_class> items;

     public MyCustomAdapter(Context context, int textViewResourceId, ArrayList<new_class> 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.row, null);
        }
        new_class o = items.get(position);
        if (o != null) {
                TextView tt = (TextView) v.findViewById(R.id.text1);
                TextView bt = (TextView) v.findViewById(R.id.text2);
                if (tt != null) {
                      tt.setText("Name: "+o.getName());                            }
                if(bt != null){
                      bt.setText("Status: "+ o.getLink());
                }
        }
        return v;
    }
}


@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    myclass try1 = new myclass();
    final List<Map<String, ?>> aaa = try1.type();

    //------------------------------------------------------
    ArrayList<new_class> my_orders = null;
    my_orders = new ArrayList<new_class>();
    new_class o1 = new new_class();
    o1.setName("perspectiva");
    o1.setLink("link1");
    new_class o2 = new new_class();
    o2.setName("perspectiva22");
    o2.setLink("link222");
    my_orders.add(o1);
    my_orders.add(o2);

    ArrayAdapter<new_class> adapter = new ArrayAdapter<new_class>(this, R.layout.row, my_orders);

    ListView lv  = (ListView)this.findViewById(R.id.ListView01);
    lv.setAdapter(adapter);
    //------------------------------------------------------


} 

and the layout row

<pre> 

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:padding="6dip">
    <ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginRight="6dip"
        android:src="@drawable/icon" />
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="0dip"
        android:layout_weight="1"
        android:layout_height="fill_parent">
        <TextView
            android:id="@+id/text1"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
            android:gravity="center_vertical"
        />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1" 
            android:id="@+id/text2"
            android:singleLine="true"
            android:ellipsize="marquee"
        />
    </LinearLayout>
</LinearLayout>
</pre>
  • 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-21T09:11:27+00:00Added an answer on May 21, 2026 at 9:11 am

    Use the below code. You had used wrong adapter for your custom listview.

    public class lay extends Activity
    {
    
        public class MyCustomAdapter extends BaseAdapter 
        {
    
            private ArrayList<new_class> items;
            Context mcontext;
            public MyCustomAdapter(Context context,ArrayList<new_class> items){
                this.items = items;
                mcontext=context;
            }
    
            @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.row, null);
                }
                new_class o = items.get(position);
                if (o != null) {
                    TextView tt = (TextView) v.findViewById(R.id.text1);
                    TextView bt = (TextView) v.findViewById(R.id.text2);
                    if (tt != null) {
                        tt.setText("Name: "+o.getName());                            }
                    if(bt != null){
                        bt.setText("Status: "+ o.getLink());
                    }
                }
                return v;
            }
    
            @Override
            public int getCount() {
                // TODO Auto-generated method stub
                return items.size();
            }
    
            @Override
            public Object getItem(int arg0) {
                // TODO Auto-generated method stub
                return null;
            }
    
            @Override
            public long getItemId(int arg0) {
                // TODO Auto-generated method stub
                return 0;
            }
        }
    
    
        @Override
        protected void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
    
    
            //------------------------------------------------------
            ArrayList<new_class> my_orders = null;
            my_orders = new ArrayList<new_class>();
            new_class o1 = new new_class();
            o1.setName("perspectiva");
            o1.setLink("link1");
            new_class o2 = new new_class();
            o2.setName("perspectiva22");
            o2.setLink("link222");
            my_orders.add(o1);
            my_orders.add(o2);
    
            //ArrayAdapter<new_class> adapter = new ArrayAdapter<new_class>(this, R.layout.row, my_orders);
            MyCustomAdapter adapter = new MyCustomAdapter(this, my_orders);
            ListView lv  = (ListView)this.findViewById(R.id.listView1);
            lv.setAdapter(adapter);
            //------------------------------------------------------
        }
    
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code, any ideas why I get this error? private SQLiteDataAdapter DA_Webfiles;
I get the following compilation error: error: expected `;' before 'it' Here's my code:
In using this code (adapted from here ) I get the following error: The
In the below code i get an error saying Error #2007: Parameter url must
Here is my jQuery code: $.get('/Home/GetList', function(data) { debugger; $('#myMultiSelect').val(data); }); Here is my
I am trying to get the code found here: http://snipplr.com/view/26643/mbprogresshud-with-an-asynchronous-nsurlconnection-call/ to work in my
Here is some code I could not get to format properly in markdown, this
Hey I have this code right here: http://pastie.org/534470 And on line 109 I get
I am trying to get some form data from POST method. Here's the code
Hey Guys, here is my code for this, the only help i get from

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.