0

嗨,我正在玩 korovyansk 滑出示例应用程序,我是 Fragment 的新手,有人能告诉我如何从另一个 Fragment 调用活动。当列表项单击它应该触发另一个活动

public class MenuFragment extends ListFragment {

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        setListAdapter(new ArrayAdapter<String>(getActivity(),
                android.R.layout.simple_list_item_1, new String[] { " First", " Second", " Third", " Fourth", " Fifth", " Sixth"}));
        getListView().setCacheColorHint(0);
    }

    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);
        ((MenuActivity)getActivity()).getSlideoutHelper().close();

    }


}
4

1 回答 1

2

你可以做一些简单的事情如下

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    Intent exampleIntent = new Intent(getActivity().getApplicationContext(), Example.class);
    exampleIntent.putExtra("ARGS", Var);
    startActivity(exampleIntent);
}
于 2013-01-22T13:39:36.607 回答