我可以设置一个页脚在Android的一个空的ListView? [英] Can i set a footer to an empty listview in android?

查看:120
本文介绍了我可以设置一个页脚在Android的一个空的ListView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道些什么?结果
我正要如果我能在android系统页脚添加到空的ListView有点好奇。我检查的ListView页脚的文档,但他们都没有提到任何与此相关的。所以,只是想知道是否有可能?

What i want to know?
I was little curious about if i can add a footer to an empty ListView in android. I checked the documentation of ListView footer but they haven't mentioned anything related to this. So just wanted to know if it is possible?

为什么我需要这个?结果
其实我已经EDITTEXT在我的应用程序(搜索框),这将接受字符作为来自用户的输入。在此输入的文字,我会做DB&放一些搜索的基础;显示在ListView匹配结果。什么,我打算做的是在ListView控件的底部(类似页脚),将提供一个扩展的搜索选项,用户显示一个按钮。

Why i need this?
Actually i have edittext(search box) in my application which will accept characters as input from user. On the basis of this entered text i will do some search in DB & display the matching results in the ListView. What i am planning to do is to display a button at the bottom of ListView(something like footer) which will provide a extended search option to user.

有些code,以供参考:

Some code for reference :

    @Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
}

@Override
public void afterTextChanged(Editable s)
{
    strGuestCardToSerach = s.toString();

    if(strGuestCardToSerach.equals(""))
    {
        if(listview.getFooterViewsCount() > 0)
        {
            listview.removeFooterView(footerView);
            listviewAdapter.notifyDataSetChanged();
        }
    }
    else
    {
        if(listview.getFooterViewsCount() == 0)
        {
            footerView = inflater.inflate(R.layout.footer_view_layout, null);
            listview.addFooterView(footerView);
            listview.setAdapter(recentGuestAdapter);
            listviewAdapter.notifyDataSetChanged();
        }
    }
}

@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3)
{
}  

@Edit:结果
一旦你在ListView中至少包含一个条目它的工作。所以,只是想了解如果在所有有可能一个页脚添加到空的ListView。

@Edit :
It does work once you have at least one entry in the ListView. So just wanted to understand if at all it is possible to add a Footer to an empty ListView.

先谢谢了。

推荐答案

我张贴这种以防万一,如果有人正在寻找类似的功能我的。答案是否定的,你不能一个页脚视图添加到空的ListView。为了实现类似的功能,你将不得不建立自己的布局和放大器;明确地将其添加到ListView&放大器;管理它的状态。

I am posting this just in case if anyone is looking for the similar functionality as mine. Answer is NO, you can't add a footer view to an empty ListView. To achieve the similar functionality you will have create your own layout & add it explicitly to the ListView & manage it's state.

Rupesh

这篇关于我可以设置一个页脚在Android的一个空的ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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