我正在使用片段代替选项卡,在上面我正在显示一个列表视图,如果我单击特定列表列,则由于启动了新活动而启动了一个新的 fragmentActivity 选项卡(片段)消失了,但我想要选项卡(片段)也应该保留在新屏幕中,我该怎么办..
活动代码如下。
公共类 FriendsFragment 扩展 ListFragment{
public static String[] friendsaddoptions=new String[]{
"Fox User","FaceBook","Email","Twiter","SMS"
};
ListView listview;
Friends_Names_List_Adapter friendsnameslistadapter;
JSONArray dataJsonObject;
Button add;
Button back;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.friends_list, container,false);
listview=(ListView)view.findViewById(android.R.id.list);
add=(Button) view.findViewById(R.id.button_add);
back=(Button)view. findViewById(R.id.button_back);
back.setVisibility(View.INVISIBLE);
FriendsFragmentData dataobserver=new FriendsFragmentData();
ServerManager.getInstance().addObserver(dataobserver);
ServerManager.getInstance().readLoopForFriends_Names_List(AppConstances.Friends_Names_List);
if(friendsnameslistadapter==null)
friendsnameslistadapter=new Friends_Names_List_Adapter(getActivity(), new JSONArray());
listview.setAdapter(friendsnameslistadapter);
add.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) { /*Intent in=new Intent(getActivity().getBaseContext(), FriendsNamesAddActivity.class);
startActivity(in);*/
ArrayAdapter< String> adapter=new ArrayAdapter<String>(getActivity().getBaseContext(), R.layout.friends_add_listitem,R.id.friends_add_option,friendsaddoptions);
listview.setAdapter(adapter);
if(adapter!=null)
back.setVisibility(View.VISIBLE);
listview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position,
long id) {
Intent intent=new Intent(getActivity().getBaseContext(),FoxUserActivity.class);
startActivity(intent);
}
});
if(adapter!=null)
{
add.setVisibility(View.INVISIBLE);
}
}
});
如何将 FragmentActivity 作为屏幕的一部分启动,以便每个活动都可以看到选项卡(片段)。