具有单选模式的ListView需要自动选择第一个项目并调用其onitemclicklistener

dra*_*sia 2 android listview

所以我使用SingleView模式启用ListView.我有一个列表项背景的选择器,它正确地更改为激活状态.

使用.setSelected()不会.

即使我获得该列表项的视图并将其状态设置为激活它仍然不起作用.

到目前为止,这是最好的解决方案,我想出了,但setActivated基本不工作,我有重复了onItemClickListener的代码倒是setActivate().

InformationListAdapter adapter = new InformationListAdapter(getActivity().getApplicationContext(), info.infoSections);
lv.setAdapter(adapter);  
View v=adapter.getView(0, null, null);
v.setActivated(true);

InformationSection item = (InformationSection)lv.getItemAtPosition(0);
InformationWebFragment webFrag = (InformationWebFragment) getFragmentManager().findFragmentById(R.id.InfoWebFragment);
webFrag.updateDisplay(item);
Run Code Online (Sandbox Code Playgroud)

ale*_*leb 13

要自动选择第一项呼叫:

listView.setItemChecked(0, true);
Run Code Online (Sandbox Code Playgroud)