Android fragments 如何隐藏当前片段
这个标题几乎概括了这一点。我想获取视图所在的当前片段,单击视图可以隐藏当前片段。我知道我可以使用replace删除它并添加另一个,但我只想隐藏当前片段。我的片段类是Android fragments 如何隐藏当前片段,android-fragments,back-stack,Android Fragments,Back Stack,这个标题几乎概括了这一点。我想获取视图所在的当前片段,单击视图可以隐藏当前片段。我知道我可以使用replace删除它并添加另一个,但我只想隐藏当前片段。我的片段类是 public class Article extends Fragment { ImageView Backing,SearchIcon; ListView listView; EditText textToSearch; Activity context
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);
}
}