Android的列表视图与页眉和页脚按钮 [英] Android listview with header and footer buttons

查看:180
本文介绍了Android的列表视图与页眉和页脚按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

乡亲! 我需要这样的布局:我有ListView和我需要把对顶部和它的底部,即按钮时用户滚动列表的末尾,他可以看到底部的按钮,当用户在顶部列表中,他可以看到顶部的按钮。但是,当用户是中间列表视图中,他看不到这些按钮。我有不知道该怎么做。感谢您的帮助。

更新

 的ListView =(ListView控件)findViewById(R.id.listSearchResults);

        LayoutInflater充气= this.getLayoutInflater();

        查看标题= inflater.inflate(R.layout.list_header,NULL);

        btnBack =(按钮)header.findViewById(R.id.btnBack);
        btnBack.setOnClickListener(本);
        btnBack.setEnabled(假);

        listView.addHeaderView(头);

        查看尾部= inflater.inflate(R.layout.list_footer,NULL);

        btnForward =(按钮)footer.findViewById(R.id.btnForward);
        btnForward.setOnClickListener(本);
        btnForward.setEnabled(假);
        listView.addFooterView(页脚);
 

解决方案

首先建立两个布局文件。喜欢的 footer_layout.xml &放大器; header_layout.xml 并添加footerview-headerview列表视图

  LayoutInflater吹气= activity.getLayoutInflater();
的LinearLayout listFooterView =(的LinearLayout)inflater.inflate(
            R.layout.footer_layout,NULL);

list.addFooterView(listFooterView);


的LinearLayout listHeaderView =(的LinearLayout)inflater.inflate(
                R.layout.header_layout,NULL);

    list.addHeaderView(listHeaderView);
 

folks! I need to make such layout: I've got listview and I need to put buttons on top and on the bottom of it, i.e. when user scrolls list to the end, he can see bottom button, and when user is on the top of list, he can see top button. But when user is 'in the middle' of listview, he can't see those buttons. I've got no idea how to do it. Thanks for help.

UPDATE

listView=(ListView)findViewById(R.id.listSearchResults);

        LayoutInflater inflater=this.getLayoutInflater();

        View header=inflater.inflate(R.layout.list_header, null);

        btnBack=(Button)header.findViewById(R.id.btnBack);
        btnBack.setOnClickListener(this);
        btnBack.setEnabled(false);

        listView.addHeaderView(header);

        View footer=inflater.inflate(R.layout.list_footer, null);

        btnForward=(Button)footer.findViewById(R.id.btnForward);
        btnForward.setOnClickListener(this);
        btnForward.setEnabled(false);
        listView.addFooterView(footer);

解决方案

First create two layout file. like as footer_layout.xml & header_layout.xml and add footerview-headerview in list view

LayoutInflater inflater = activity.getLayoutInflater();
LinearLayout listFooterView = (LinearLayout)inflater.inflate(
            R.layout.footer_layout, null);

list.addFooterView(listFooterView);


LinearLayout listHeaderView = (LinearLayout)inflater.inflate(
                R.layout.header_layout, null);

    list.addHeaderView(listHeaderView);

这篇关于Android的列表视图与页眉和页脚按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆