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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:02:01+00:00 2026-05-20T02:02:01+00:00

I want the class below to display some textviews/buttons/spinners, and also a ListView containing

  • 0

I want the class below to display some textviews/buttons/spinners, and also a ListView containing parsed data. However the listview/adapter/addview are causing some trouble.
Heres the error I’m getting:

java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView

I’ve a feeling its to do with my xml files, but Im not too sure.
Here’s my code:

public class StatisticsScreen extends ListActivity{

private List<Message> messages; 

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.statisticsscreen);

    loadFeed();

    //other textviews and listeners added
}

private void loadFeed() {

    try{
        BaseFeedParser parser = new BaseFeedParser();
        messages = parser.parse();
        List<String> titles = new ArrayList<String>(messages.size());
        for (Message msg : messages){
            titles.add(msg.getTitle());
        }
        ArrayAdapter<String> adapter = 
        new ArrayAdapter<String>(this, R.layout.xmldatarow,titles);

        this.setListAdapter(adapter);           
    } catch (Throwable t){
        Log.e("AndroidNews",t.getMessage(),t);
    }       
}

My statisticsscreen xml:

<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">

<LinearLayout android:id="@+id/statsviewlayout"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="@color/black">
    //other layouts/textviews/buttons added
    <include  layout="@layout/xmllayout" android:id="@+id/xmllist" />

</LinearLayout>
</ListView>

xmllayout xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <ListView android:id="@+id/xmllist" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"/>
    </LinearLayout>

xmldatarow is a simple textView.

EDIT:

Ok so ive updated some of the files and I’m getting a runtime exception error:

Your content must have a ListView whose attribute is ‘android.R.id.list’

here are the updated files:

class:

setContentView(R.layout.statisticsscreen);    
loadFeed();        
getListView().addHeaderView(View.inflate(this, R.layout.xmllayout, null));

private void loadFeed() {
    try{
        BaseFeedParser parser = new BaseFeedParser();
        messages = parser.parse();
        List<String> titles = new ArrayList<String>(messages.size());
        for (Message msg : messages){
            titles.add(msg.getDate());
        }
        ArrayAdapter<String> adapter = 
            new ArrayAdapter<String>(this, R.layout.xmldatarow,titles);
        this.setListAdapter(adapter);
    } catch (Throwable t){
        Log.e("AndroidNews",t.getMessage(),t);
    }       
}

My statsscreenlayout stil has all of the linearlayouts with textviews etc. and I deleted this from it:

<include  layout="@layout/xmllayout" android:id="@+id/xmllist" />

Then my other two layouts are a simple textview(xmldatarow), and a listview(xmllayout).
So just to clarify, there isnt any listview or any ‘include’ in my statsscreenlayout.

Any advice? Thanks

  • 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-20T02:02:01+00:00Added an answer on May 20, 2026 at 2:02 am

    You can’t inflate views directly into a listview like that. I think you may be looking for ListView‘s addHeaderView or addFooterView methods. Make sure to call them before calling setListAdapter.

    EDIT: To spell it out fully: Assuming you wanted statsviewlayout at the top of your list: Don’t put the LinearLayout directly in the ListView element (ListViews shouldn’t have children). Put it in a separate xml file (say, statsview.xml) and do something like this in your onCreate:

    getListView().addHeaderView(View.inflate(this, R.layout.statsview.xml, null));
    

    Also see this old android-beginners post.

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

Sidebar

Related Questions

I want to display some text below each grid image. Please see my code
The class below is my delete class, i want to delete the users from
I want expose WebClient.DownloadDataInternal method like below: [ComVisible(true)] public class MyWebClient : WebClient {
I want to display calendar with some notes/events which i stored in database. In
I want to use prepared statement to insert and update data in mysqli, Below
Take the example classes below. I want to display the customer and two addresses
The code below plots some simple x-y data, but it has two problems that
I am trying to develop a page to display student/class results by subject/teacher. Some
i want set class for repeater when doPostBack for those dataID i wan but
I'm working on a new class to wrap XML handling. I want my class

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.