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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:50:58+00:00 2026-05-26T17:50:58+00:00

I have one custom ListView called AreasListView which I’ve included in the XML file.

  • 0

I have one custom ListView called AreasListView which I’ve included in the XML file. The only things that differentiate this from a ListView are the following lines of code:

private void setFooter(){
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View footer = inflater.inflate(R.layout.areas_list_add_item, null);
    addFooterView(footer);
}

@Override
public void setAdapter(ListAdapter adapter)
{
    super.setAdapter(adapter);
}

The footer is added by the list itself in the constructor.

To this list I am setting a custom adapter in the onCreate method. Later on (when the user clicks on the footer that the custom list view has) another activity is started for result. When that one returns a new item is added to the ArrayList that sits under the custom adapter.

Here’s the adapter code:

public class AreasAdapter extends BaseAdapter

{

private Manager manager;

public AreasAdapter(Manager mgr){
    this.manager = mgr;
}

@Override
public int getCount()
{
    return manager.getAreas().size();
}

@Override
public Object getItem(int arg0)
{
    return manager.getAreas().get(arg0);
}

public Area getArea(int index){
    return manager.getAreas().get(index);
}

@Override
public long getItemId(int arg0)
{
    return arg0;
}

@Override
public int getItemViewType(int arg0)
{
    return Adapter.IGNORE_ITEM_VIEW_TYPE;
}

@Override
public View getView(int arg0, View arg1, ViewGroup arg2)
{
    AreasListItem viewToReturn = null;
    if (arg1 != null){
        viewToReturn = (AreasListItem)arg1;
    } else {
        LayoutInflater inflater = (LayoutInflater) arg2.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        viewToReturn = (AreasListItem)inflater.inflate(R.layout.areas_list_item, null);
    }
    viewToReturn.setArea(manager.getAreas().get(arg0));
    return viewToReturn;
}

@Override
public int getViewTypeCount()
{
    return 1;
}

@Override
public boolean hasStableIds()
{
    return false;
}

@Override
public boolean isEmpty()
{
    return (manager.getAreas().size() == 0);
}

@Override
public void registerDataSetObserver(DataSetObserver arg0)
{
    super.registerDataSetObserver(arg0);
}

@Override
public void unregisterDataSetObserver(DataSetObserver observer)
{
          super.unregisterDataSetObserver(observer);

}

@Override
public boolean areAllItemsEnabled()
{
    return true;
}

@Override
public boolean isEnabled(int position)
{
    return true;
}

}

After I receive the result I try to call notifyDataSetChanged, but it doesn’t work. Code:

    if (resultCode == Activity.RESULT_OK){
            Area resultArea = (Area) returnIntent.getExtras().get(ActivityAreaAdd.EXTRA_AREA);
                service.getManager().addArea(resultArea);
//              TODO figure out how to update the list with the newly added areas
                ((AreasAdapter)(((HeaderViewListAdapter) list.getAdapter()).getWrappedAdapter())).notifyDataSetChanged();
        }

What is it that I am doing wrong? I’ve tried the following so far:

  • change AreasListView so that I don’t get a HeaderListViewAdapter and try calling notifyDataSetChanged();
  • call list.invalidate();
  • call list.invalidateViews();
  • call list.requestLayout();

UPDATE:
I tried using @Jack’s solution and it doesn’t work. Here’s what I did:
from my onActivityResult:

    if (resultCode == Activity.RESULT_OK){
            Area resultArea = (Area) returnIntent.getExtras().get(ActivityAreaAdd.EXTRA_AREA);
//              TODO figure out how to update the list with the newly added areas
                ((AreasAdapter)(((HeaderViewListAdapter) list.getAdapter()).getWrappedAdapter())).addArea(resultArea);
            }

and the corresponding code from AreasAdapter:

public void addArea(Area a){
    manager.addArea(a);
    notifyDataSetChanged();
}
  • 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-26T17:50:59+00:00Added an answer on May 26, 2026 at 5:50 pm

    I fixed the problem. Apparently what was needed was to remove the @Override setAdapter method from my custom list.

    It is weird, since all it contained was a call to super.setAdapter(adapter).

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

Sidebar

Related Questions

I have created a custom listview that is populated using a row.xml file. Each
I have a custom listview row whose XML has one ImageView and three TextViews
I have one custom ListView which contains one ImageView and one TextView, and I
I have one seekbar in my custom listview . Now i dont want that
I have created a custom listview that have one webview per element. My problem
I have a custom listview which changes size when one of the rows is
I have a custom listview in which one textview and one checked box is
I have two ItemsControls, one a ListView, and one a custom control I am
I have a collection of custom entity objects one property of which is an
I have a datagridview in which one column contains a custom class, which I

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.