【发布时间】:2012-02-22 03:15:36
【问题描述】:
我需要你的帮助 :) 我有一个 EditText,下面有一个 ExpandableListView。我使用了带有组/子的 BaseExpandableListAdapter。我希望当用户在 EditText 中写入时,ExpandableListView 仅显示插入文本的组(项目)。 我认为我必须创建一个过滤器。 这里有一段我的源代码。有人可以帮我吗?提前谢谢你
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState
setContentView(R.layout.main);
et = (EditText) findViewById(R.id.filterText);
et.setSingleLine();
et.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
if (et.getText().toString().equals(""))
elv.setBackgroundColor(Color.BLACK);
else
{
elv.setBackgroundColor(Color.WHITE);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
elv=getExpandableListView();
mAdapter = new MyExpandableListAdapter(fields_select,description);
elv.setAdapter(mAdapter);
class MyExpandableListAdapter extends BaseExpandableListAdapter {
......
}
【问题讨论】:
标签: android filter android-edittext adapter expandablelistview