How to add a footer in ListView?

前端 未结 7 1806
时光取名叫无心
时光取名叫无心 2020-11-22 09:35

I am developing an application,In my application,I am using Listview for displaying data using dom parsing,I want to footer in listview,when i click footer additional more d

7条回答
  •  半阙折子戏
    2020-11-22 09:58

    Create a footer view layout consisting of text that you want to set as footer and then try

    View footerView = ((LayoutInflater) ActivityContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
    ListView.addFooterView(footerView);
    

    Layout for footer could be something like this:

    
    
    
        
    
        
        
     
    

    The activity class could be:

    public class MyListActivty extends ListActivity {
        private Context context = null;
        private ListView list = null;
    
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            list = (ListView)findViewById(android.R.id.list);
    
            //code to set adapter to populate list
            View footerView =  ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
            list.addFooterView(footerView);
        }
    }
    

提交回复
热议问题