ListView标题onBackPressed()

时间:2013-06-03 09:01:19

标签: android listview

我正在努力使用Android中的ListView及其标题。我正在使用ListFragment,在onViewCreated中我正在这样做:

        View header = getActivity().getLayoutInflater().inflate(R.layout.route_list_header, null);
        header.setLayoutParams(new       ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT,
                ListView.LayoutParams.WRAP_CONTENT));
        getListView().addHeaderView(header);

        RouteAdapter adapter = new RouteAdapter(getActivity(), routes);
        setListAdapter(adapter);
        getListView().setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                MapFragment fragment = new MapFragment();
                fragment.showRoute(routes.get(position - 1).getRoutePoints());
                getActivity().getFragmentManager().beginTransaction().addToBackStack("map")
                        .replace(R.id.content_frame, fragment).commit();
            }
        });

它工作正常,但问题是当我换到另一个片段然后我按回按钮。我无法再添加标题,因为我之前已经调用了setAdater(在停止片段之前)。我该怎么办?

0 个答案:

没有答案