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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:27:48+00:00 2026-05-18T01:27:48+00:00

i have a problem with displaying listview. i have tabbed activity and one of

  • 0

i have a problem with displaying listview. i have tabbed activity and one of them contains listview. here’s the code:

result.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  android:id="@+id/Layout_result"
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" 
  android:background="@drawable/papero3">   
    <ListView 
      android:id="@+id/resultListView" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent">

        <TextView android:text="@string/main_no_items" 
            android:id="@+id/empty" 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent">
        </TextView>

    </ListView>
</LinearLayout>

list_item.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/listItem"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" 
  android:orientation="horizontal" 
  android:paddingLeft="10px" 
  android:paddingRight="10px" 
  android:paddingTop="5px" 
  android:paddingBottom="5px">


    <TextView android:text="This is object's name" 
    android:id="@+id/result_item_name_object" 
    android:layout_height="wrap_content" 
    android:singleLine="false"
    android:gravity="left"
    android:textSize="18sp" android:layout_width="260px">
    </TextView>


    <TextView android:text="null" 
    android:id="@+id/result_item_distance" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:gravity="right"
    android:textSize="15sp" android:paddingLeft="10px">
    </TextView>         

</LinearLayout>

main code:

ListView resultList = (ListView)findViewById(R.id.resultListView);
ItemAdapter m_adapter = new ItemAdapter(this, R.layout.list_item, itemsFound);  
resultList.setAdapter(m_adapter);

viewItems = new Runnable(){  
    @Override  
    public void run() {
        searchItems();     
    }  
}; 

Thread thread =  new Thread(null, viewItems, "Searching");  
thread.start();



private class ItemAdapter extends ArrayAdapter<Item>{

        private ArrayList<Item> items;

        public ItemAdapter(Context context, int textViewResourceId,
                ArrayList<Item> objects) {
            super(context, textViewResourceId, objects);
            this.items = objects;
        }

        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, null);
            }

            Item item = (Item) items.get(position);

            if (item != null){
                TextView resName = (TextView) v.findViewById(R.id.result_item_name_object);
                TextView resDistance = (TextView) v.findViewById(R.id.result_item_distance);  

                if (resName != null){
                    resName.setText(item.name);
                }

                if (resDistance != null){
                    resDistance.setText(item.distance);
                }           
            }       
            return v;           
        }           
    }

private Runnable returnRes = new Runnable() {
    @Override
    public void run() {
        if(itemsFound != null && itemsFound.size() > 0){
            m_adapter.notifyDataSetChanged();  
            int count = itemsFound.size();
            for(int i=0; i < count; i++)  
                m_adapter.add(itemsFound.get(i));  
        }
        m_ProgressDialog.dismiss();
        m_adapter.notifyDataSetChanged();  
    }
};

for the first i get “UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView” in result.xml layout window, but when i clean up textview from listview in resut.xml that problem disappear, but comes new one:

11-10 10:39:42.623: ERROR/AndroidRuntime(720): android.content.res.Resources$NotFoundException: String resource ID #0x304
11-10 10:39:42.623: ERROR/AndroidRuntime(720):     at android.content.res.Resources.getText(Resources.java:200)
/*and so on*/
  • 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-18T01:27:48+00:00Added an answer on May 18, 2026 at 1:27 am

    fixed 🙂 dont forget that (textview).settext() requires resource id, so dont forget to convert your numerical data to string 🙂

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

Sidebar

Related Questions

I have a problem displaying the results of an sql query into a ListView
I have two activities one displaying map view and another listview, the main objective
I'm currently having a problem in displaying some stuff in ListView . I have
Ok I have a ListView that has 2 GridViewColumns one displaying a number and
I have an problem to displaying text below listview.when items are more in list
I have a problem displaying a View Controller when calling a segue from code
I have problem with displaying adsense ads in ie7 google adsense adds an iframe
I have a problem displaying non- ASCII characters in Matplotlib, these characters are rendered
I have a problem displaying zebra list after filtering results. I have a zebra
I'm generating dynamic HTML inside Delphi. I have no problem displaying UTF-8 strings inside

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.