我正在开发一个应用程序,我需要ListFragments
在同一活动上调用多个。ListFragment
它包含有 10 行的主父级。通过单击每一行,我需要像这样ListView
在父级旁边打开新子级。我的编码是ListView
public class FragmentListArray extends Activity {
static String[] TITLES =
{
"Henry IV (1)",
"Henry V",
"Henry VIII",
"Richard II",
"Richard III",
"Merchant of Venice",
"Othello",
"King Lear"
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create the list fragment and add it as our sole content.
if (getFragmentManager().findFragmentById(android.R.id.content) == null) {
ArrayListFragment list = new ArrayListFragment();
getFragmentManager().beginTransaction().add(android.R.id.content, list).commit();
}
}
public static class ArrayListFragment extends ListFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1, FragmentListArray.TITLES));
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
// here i need to achieve my childview click listener..
}
}
}
我不知道如何设置 onitem 点击监听器。帮助我实现上述目标。提前致谢。