导航:首页 > 净水问答 > android过滤listview内容

android过滤listview内容

发布时间:2021-03-21 01:20:53

1. android listView 过滤 不显示提示区域

用ListView来加载数据的页面不需要在ListView的外面再套上一个ScollView,因为ListView本身可以滚动显示数据。有时我们页面中除要用ListView显示列表数据之外还要显示其它数据,这时候就需要在整个页面最个层套上一个Scollview,否则显示就可能出现问题(比如在ListView上面已经有很多其它数据,显示在手机上直接导致ListView看不见了,这时就要在整个屏幕布局加ScollView实现滑动界面),用过ScollView嵌套ListView的朋友都知道,在不做任务处理的情况下,ListView的数据只能显示一行多一点点,其它的就看不到了,这个问题怎么解决呢?通常我们可以有下面两种方式:
1,计算高度:
private int totalHeight=0;

public static void setListViewHeight(ListView listView){
/*得到适配器*/
Aadpter adapter = listView.getAdapter();
/*遍历控件*/
for (int i = 0; i < adapter .getCount(); i++) {
View view = adapter .getView(i, null, listView);
/*测量一下子控件的高度*/
view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
totalHeight+=view.getMeasuredHeight();
}
/*控件之间的间隙*/
totalHeight+=listView.getDividerHeight()*(listView.getCount()-1);

/*2、赋值给ListView的LayoutParams对象*/
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight;

listView.setLayoutParams(params);
}
2,重写ListView的onMeasure:
public class WholeListView extends ListView {

public WholeListView (Context context) {
super(context);
}

public WholeListView (Context context, AttributeSet attrs) {
super(context, attrs);
}

public WholeListView (Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}

当然上面两个方法对GridView及Expandlistview也是有效的。

2. 我用searchview和listview做的安卓应用的一个搜索功能,怎么才能把屏幕中的这个输入的内容的黑色方块去掉

自己写 onQueryTextChange 里的方法,过滤数据

3. Android 删除listview中的item

listview item的根布局中增加
android:descendantFocusability="blocksDescendants"
表示子控件可以获取焦点
这样,就可以点击item中的button了
这个代码有点多,其实很简单的
你就用自定义adapter 然后在getView方法中对每个item的button注册一个点击事件

4. 如何在ListView中添加过滤

var
i:integer;
begin
fori:=0toListView1.Items.Count-1do
begin
ifPos('你的字符串',ListView1.Items[i].Caption)>0then
找到
else
没找到
end;
end;

5. android listview项如何实现中文过滤,类似如下效果:

呃。是要实现提示BA?
网上搜下代码吧。。有点复杂。

6. android 获取listview每一项的内容

//获得选中项的HashMap对象
HashMap<String,String> map=(HashMap<String,String>)myListView.getItemAtPosition(arg2);
String tid=map.get("tid");

7. android开发 如何获得listview里面的内容

我给你一个地址吧!你去看看!http://ajava.org/course/j2me/16894.html!另外向你求教下,你的android程序调用web服务是怎么实现的?我是用ksoap2 连接的webservice,取到的数据在用正则表达式过滤才能显示,我感觉我的方式不对,但是找不到合适的,不知道可否给一下你的资料邮箱[email protected]!谢谢了!

final ArrayList<HashMap<String, Object>> users = new ArrayList<HashMap<String, Object>>();
for (int i = 0; i < 10; i++) {
HashMap<String, Object> user = new HashMap<String, Object>();
user.put("img", R.drawable.user);
user.put("username", "姓名(" + i+")");
user.put("age", (20 + i) + "");
users.add(user);
}
SimpleAdapter saImageItems = new SimpleAdapter(this,
users,// 数据来源
R.layout.user,//每一个user xml 相当ListView的一个组件
new String[] { "img", "username", "age" },
// 分别对应view 的id
new int[] { R.id.img, R.id.name, R.id.age });
// 获取listview
ListView myListView =((ListView) findViewById(R.id.users));
myListView.setAdapter(saImageItems);
myListView.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
// TODO Auto-generated method stub

String aa=(String) users.get(arg2).get("username");

Toast.makeText(ListViewTest.this, "你点击了第"+arg2+"项的"+aa,Toast.LENGTH_SHORT).show();
}
});

8. 如何快速过滤ListView控件中重复记录,10W条以上的数据

用ListView显示10多万的数据,显然是不能用Items.Add这样传统的方法加载的,能把界面给拖死.使用OwnerData的话,数据是内存中构建的,只要算法不是很差,依现在CPU的速度,合并同类项问题不大.

9. 怎样添加数据到ListView后过滤重复

来源是数据库的话可以考虑在取出来数据的时候就去重 例如: select distinct * form table

10. Android开发,SearchView过滤ListView,弹出类似Toast的黑框.来大神给个具体的解决办法,要实测有效的!

public boolean onQueryTextChange(String newText) {
if (TextUtils.isEmpty(newText)) {
adapter.getFilter().filter("");
Log.i("Nomad", "onQueryTextChange Empty String");
placesListView.clearTextFilter();
} else {
//主要是这句写上就没黑框了
adapter.getFilter().filter(newText.toString());
}
return true;
}
public boolean onQueryTextSubmit(String query) {
Log.i("Nomad", "onQueryTextSubmit");
return false;
}

阅读全文

与android过滤listview内容相关的资料

热点内容
纳滤实验设备 浏览:772
抚州市污水处理厂环评 浏览:346
净水烧水有水垢 浏览:516
帕拉丁空调滤芯怎么样 浏览:978
蒸馏过程是一个什么过程 浏览:534
污水排放验收记录表 浏览:874
vv7用的什么空气净化器 浏览:649
超滤膜化学清洗资料 浏览:642
如何去除蹲坑里的水垢 浏览:972
生活污水什么工艺能得到五类水 浏览:677
半导体纯水toc要求多少 浏览:998
树脂赶集网 浏览:946
tzl75净水器滤芯怎么安装 浏览:663
集米m2即热式饮水机怎么解除童锁 浏览:98
鱼缸过滤器自制视频教程 浏览:297
解释一下这个滤芯是什么意思 浏览:439
成品缸有过滤器吗 浏览:413
饮水机没有ro膜有什么区别 浏览:374
过滤效率百分之九十能防 浏览:315
大风量油烟净化器清洗多少钱一套 浏览:347