在我的项目中,我有4个ListView。 2 ListViews在Activities中,其他2个ListViews在Fragments中。在setTextFilterEnabled(true)之后,Filtering仅在第一个Activity中工作..在Web上进行一些搜索之后,我得到了问题,其他列表没有Focus,因此Filtering未启用..现在它适用于两个活动,但不适用于我的碎片:( ..
有人有想法吗?
以下是一些代码段。
NCViewPagerAdapter myAdapter = new NCViewPagerAdapter(getSupportFragmentManager(), this);
viewPager = (ViewPager) findViewById(R.id.viewpager);
viewPager.setAdapter(myAdapter);
viewPager.setCurrentItem(1);
viewPager.setOnPageChangeListener(new OnPageChangeListener()
{
@Override
public void onPageSelected(int pos)
{
switch (pos)
{
case PAGE_MEKA:
{
//Cause to Enable Filtering the View have to get Focus..
ListView lv = (ListView) ctx.findViewById(R.id.listMekaForNC);
lv.requestFocus();
}
case PAGE_SCHLAG_KOMB:
{
ListView lv = (ListView) ctx.findViewById(R.id.listViewSchlag);
lv.requestFocus();
}
}
}
和
ListView lw = (ListView) v.findViewById(R.id.listViewSchlag);
List<Nutzungscode> schlaege = Data.getService().getSchlagKombinationen(nc.getID());
lw.setAdapter(new MyListAdapter(this.getActivity(), R.layout.mylistitem, schlaege,Nutzungscode.class,new String[]{"getID","getName"}));
lw.setTextFilterEnabled(true);