如何隐藏当前片段

时间:2014-07-21 11:31:54

标签: android-fragments back-stack

标题几乎总结了它。我想获取视图所在的当前片段,并且视图的 onclick 隐藏当前片段。我知道我可以使用替换删除它并添加其他但我只想隐藏当前片段。我的片段类是

public class Article extends Fragment
    {
        ImageView Backing,SearchIcon;

        ListView listView;

        EditText textToSearch;

        Activity context;

        String url="http://tables.php";

        View V; //SET THE FRAGMENTS VIEW AS A CLASS VARIABLE HERE


        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState)
        {
             if(V == null)
             { 
                V = inflater.inflate(R.layout.article, container, false);

                context = getActivity();

                listView = (ListView) V.findViewById(R.id.art_listview);

                Backing = (ImageView)V.findViewById(R.id.art_back);

                SearchIcon = (ImageView)V.findViewById(R.id.search_icon);

                listView = (ListView) V.findViewById(R.id.art_listview);

                textToSearch = (EditText)V.findViewById(R.id.art_search_ev);

                eventHandling();

                new ArticleTask(getActivity(), url, listView).execute(url);
             }

             else
                { //IF ALREADY INSTANTIATED USE SAME OLD V 
                  //  ((ViewGroup)V.getParent()).removeView(V);
                }

            return V;// return super.onCreateView(inflater, container, savedInstanceState);
        }
    }

0 个答案:

没有答案