Android ListActivity - fixed header and footer

后端 未结 3 1734
时光说笑
时光说笑 2021-01-02 21:58

Is it possible to set header and footer at ListActivity to be fixed at the top and the bottom, so only the content (list) is scrolling, not also header and footer?

I

3条回答
  •  没有蜡笔的小新
    2021-01-02 22:18

    According to project scenario, this methodology would be better than any other approach, because if you want to customize the header and footer, you can make changes in appropriate header and footer layout. In your layout xml file follow this :

    In main.xml

     
     
    
       
    
       
    
        
     
    

    In header.xml

     
    
        
       
    

    In footer.xml

      
    
         

    In Activity, Here

      public class MainActivity extends ListActivity {
    
       private ListView mListView;
       @Override
       protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            mListView = (ListView) findViewById(R.id.list_view);
            // Now you can do whatever you want
    
       }
     }
    

提交回复
热议问题