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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:28:01+00:00 2026-05-27T22:28:01+00:00

I am using a listview with paging – so I should add a listview

  • 0

I am using a listview with paging – so I should add a listview at the end of it.
I have a code – integrated from what Ifound in the web. But I see that addFooter method is called (in the two places it is mentioned) but the footer does not appear on the screen?

Relevant code:

public class GlobalBookTab extends ListActivity implements OnClickListener

{
private final String mTAG = “GlobalBook”;

private EditText                    mSearchEditText         = null;
private String                      mLastSearchString       = null;

private View                        mCategoriesView         = null;

private int                         mQueryPageNumber        = 1;
private ServerWrapper.SortByEnum    mLastSearchSorting      = SortByEnum.NO_SORTING;
private GlobalRecipeListAdapter     mListViewAdapter        = null;

private boolean                     mIsCategorySearch       = false;
private Recipe.CategoryEnum         mSearchCategory         = Recipe.CategoryEnum.NO_CATEGORY;

private ImageView                   mSortByRateView         = null;
private ImageView                   mSortByDifficultyView   = null;
private ImageView                   mSortByTimeView         = null;

private View                        mFooterView             = null;
private boolean                     mLoadingMore            = false;
private ListView                    mListView               = null;

private LayoutInflater              mInflater               = null;

/*
 * (non-Javadoc)
 * @see android.app.Activity#onCreate(android.os.Bundle)
 */
@Override
protected void onCreate( Bundle savedInstanceState )
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.global_book);

    mInflater           = ((LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE));

    mListView           = this.getListView();
    mListViewAdapter    = new GlobalRecipeListAdapter(  this, 
                                                        R.layout.recipes_list_view_entry, 
                                                        new ArrayList<Recipe>() );

    mFooterView = ((LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.listfooter, null, false);

    setListAdapter( mListViewAdapter );
}

/*
 * (non-Javadoc)
 * @see android.view.View.OnClickListener#onClick(android.view.View)
 */
public void onClick( View v )
{
    switch( v.getId() )
    {
        case R.id.searchImageViewId:
            mQueryPageNumber    = 1;
            mLastSearchSorting  = SortByEnum.NO_SORTING;
            mLastSearchString   = mSearchEditText.getText().toString();
            if( mIsCategorySearch == false )
            {
                mSearchCategory = CategoryEnum.NO_CATEGORY;
            }

            SearchButtonClicked();

        default:
            Log.e( mTAG, "Unknown clickId" );
            return;
    }
}


/**
 * Used when the search button is clicked
 */
private void SearchButtonClicked()
{
    Log.d( mTAG, "Searching for recipe - " + mSearchEditText.getText().toString() );

    performSearchBackgroundTask task = new performSearchBackgroundTask();
    task.execute();
    mFooterView = mInflater.inflate(R.layout.listfooter, null, false);
    getListView().addFooterView( mFooterView );
}

private class performSearchBackgroundTask extends AsyncTask <Void, Void, Void>  
{
    ArrayList<Recipe>               mRecipes        = null;
    private ProgressDialog          Dialog          = new ProgressDialog( GlobalBookTab.this );
    private boolean                 mExecutedOK     = false;
    private ServerException.Id      mExceptionId    = ServerException.Id.Id_MAX;

    protected void onPreExecute()
    {
        Dialog.setMessage("Please wait...");
        Dialog.show();
    }

    protected void onPostExecute(Void unused)    
    {
        if(Dialog.isShowing())
        {
            Dialog.dismiss();
        }

        if( mExecutedOK == true )
        {
            if( mRecipes.size() == 0 )
            {
                Toast.makeText( getApplicationContext(),
                                "No matching results",
                                Toast.LENGTH_LONG).show();
            }
            else
            {
                ChangeCategoriesVisibility( View.GONE );
                ChangeSortingVisibility( View.VISIBLE );

                if( mQueryPageNumber != 1 )
                {
                    mListViewAdapter.clear();
                }

                if( mRecipes != null )
                {
                    for( int i = 0; i < mRecipes.size(); ++i )
                    {
                        if( mRecipes.get( i ) != null )
                        {
                            mListViewAdapter.add( mRecipes.get( i ) );
                        }
                    }
                }

                mListViewAdapter.notifyDataSetChanged();

                // Might be more results
                if( mRecipes.size() == 5 )
                {
                    mFooterView = mInflater.inflate(R.layout.listfooter, null, false);
                    mListView.addFooterView( mFooterView );
                }
                else
                {
                    mListView.removeFooterView( mFooterView );
                }
            }
        }
        else
        {
            switch( mExceptionId )
            {
                case FAILED:
                    Toast.makeText( getApplicationContext(),
                                    "No matching results",
                                    Toast.LENGTH_LONG).show();
                    break;

                case UNABLE_TO_CONNECT_TO_SERVER:
                    Toast.makeText( getApplicationContext(),
                                    "Failed to connect to server",
                                    Toast.LENGTH_LONG).show();
                    break;
            }
        }
    }

    @Override
    protected Void doInBackground( Void... params ) 
    {
        // Do your background data fetching here
        ServerWrapper               webService  = new ServerWrapper();
        try
        {
            mRecipes = webService.SearchRecipe( mLastSearchString, 
                                                mQueryPageNumber,
                                                mLastSearchSorting,
                                                mSearchCategory );
        }
        catch( ServerException e )
        {
            mExecutedOK     = false;
            mExceptionId    = e.eId();

            return null;
        }

        mExecutedOK = true;
        return null;   
    }
}

}

  • 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-27T22:28:02+00:00Added an answer on May 27, 2026 at 10:28 pm

    You need to call addFooter method prior to setAdapter for list.
    Else header/footer wont be visible.

    Hope this solves your problem.

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

Sidebar

Related Questions

From everything I've read, it seemed that adding paging to a ListView control should
I have to show some LinearLayouts in Scroll. I am using ListView but got
i want to do sorting in the listview from code behind, and i have
I'm using a datapager control on my listview to perform paging in it. When
In past, I am using Listview and using below code can show a particular
I've been using the coding from an example from this link : The code
When I check my logs, when using ListView, I see, that getView() method of
I'm new to android. I have worked in searchbar using Listview and it's working
I have an asp:ListView control which list playlists. It has paging supported and holds
I'm using ListView to show search results. I have a Coustomized arrayListAdapter which returns

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.