我有一個ListView
與單個行中的多個TextView
。 TextView
值是名稱,組名,日期和一些隱藏字段。並在這ListView
以外的微調。一旦我從Spinner ListView
中選擇物品需要過濾。那是另一排將會消失。我已嘗試setVisibility()
方法,但效果不佳。我正在使用簡單的適配器。我怎樣才能做到這一點。請幫幫我。Listview- filter Android
我的樣例代碼爲:
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);
如何過濾列表視圖這個請大家幫忙。
我已經做到這一點使用的過濾器。謝謝您的幫助。 – Amsheer