我在一行中有ListView
个TextView
个TextView
。 ListView
值包括名称,组名,日期和一些隐藏字段。还有一个在ListView
之外的微调器。一旦我从微调器setVisibility()
中选择项目需要过滤。那是另一排将消失。我尝试 Spinner draft_filter = (Spinner) findViewById(R.id.draft_filter);
draft_filter.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
Spinner draft_spinner = (Spinner) arg0;
String selected_string = (String) draft_spinner.getSelectedItem();
//Save this String and filter the listview using this
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
ListView level1 = (ListView) findViewById(R.id.listview);
level1.setOnScrollListener(new OnScrollListener() {
public void onScrollStateChanged(AbsListView view, int scrollState) {
// TODO Auto-generated method stub
}
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
// TODO Auto-generated method stub
for (int i=0; i<level1.getChildCount(); i++)
{
// Set the Visibility of the row here
}
});
//For loading listview
//Here fillmaps is the arraylist contains hashmap values
String[] drafts = new String[] { "child_name", "age"};
int[] controls = new int[] { R.id.item1, R.id.item2};
adapter = new SimpleAdapter(getApplicationContext(), fillMaps,
R.layout.draft_observation_list_layout, drafts, controls);
level1.setAdapter(adapter);
方法,但效果不佳。我正在使用简单的适配器。我怎样才能做到这一点。请帮帮我。
我的示例代码:
{{1}}
如何过滤此列表视图请帮助。
答案 0 :(得分:0)
每次使用筛选列表值更改Spinner项目值时调用适配器。
答案 1 :(得分:0)
我尝试了很多东西,但解决方案非常简单:
((SimpleAdapter) MyActivity.this.adapter).getFilter().filter(filter_text);