mardi 26 mai 2015

List View Footer is leaving spaces and not getting removed

I am using list view footer which is just a button. Whenever i am updating the list with load more button it add extra space at the bottom. Also i am trying to remove the footer when all d data is loaded.

Initialing the button in oncreate

btnLoadMore = new Button(getActivity());
        btnLoadMore.setText("Load More");
        btnLoadMore.setWidth(700);
        btnLoadMore.setHeight(30); 

Then in post Execute

                    mainAdapter = new SimpleAdapter(  
                            getActivity(), mainfooditems,
                            R.layout.list_mealiteml, new String[] {KEY_FLFOODNAME,KEY_FLCALORIES,KEY_FLFOODID,KEY_FLFAT,KEY_FLCARBS,KEY_FLPROTEIN,KEY_FLBRAND,KEY_FLSERVING}, new int[] { 
                                R.id.nameone,R.id.uiduid,R.id.mtvfoodid,R.id.fatoutputval,R.id.carbsoutval,R.id.proteinsoutval,R.id.tvbrandnameone,R.id.tvservingone });
                    // updating listview
                    listMain.addFooterView(btnLoadMore);
                    listMain.setAdapter(mainAdapter);
                    mainAdapter.notifyDataSetChanged();
state3();

And state3 is as follows:

public void state3(){
        search.clearFocus();

        setListViewHeightBasedOnChildren(listMain);
        setListViewHeightBasedOnChildren(listCustom);
        setListViewHeightBasedOnChildren(listRecent);
        tvError.setVisibility(View.INVISIBLE);
        tvMessage.setVisibility(View.INVISIBLE);
        finalfoodidint=Integer.parseInt(finalfoodid);
        if(finalfoodidint > oldlastid){

            System.out.println("1.5 + " + finalfoodidint);
            System.out.println("1.6 + " + oldlastid);

        }
        else if(finalfoodidint == oldlastid){
            //listMain.removeFooterView(btnLoadMore);
            listMain.removeFooterView(btnLoadMore);
            System.out.println("1.7 + " + finalfoodidint);
            System.out.println("1.8 + " + oldlastid);
        }
        else{
            listMain.removeFooterView(btnLoadMore);
            System.out.println("1.9 + " +finalfoodidint);
            System.out.println("1.10 + " +  oldlastid);
        }
    }

It appears

Aucun commentaire:

Enregistrer un commentaire