我可以使用从列表片段中选择的项目开始另一个片段。在第二个片段中,我有一个列表视图,我只想在从第一个片段单击列表项时显示该视图。但是,一旦我开始活动,我就会在第二个片段中获得列表视图项目。
public class MyNewFragment extends ListFragment{
String[] newLists ={
"hey",
"hello Control",
"what",
"3D gone",
"chindiyaa",
"hat sala",
"Heheheheh",
"chal nikal",
};
/*@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
//return inflater.inflate(R.layout.justatestlayout, container, false);
View view = inflater.inflate(R.layout.new_fragment_layout, container, false);
ListView lv2 = (ListView) view.findViewById(R.id.listView3);
lv2.setAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, newLists));
return view;
}*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ListAdapter myListAdapter = new ArrayAdapter<String>(
getActivity(),
android.R.layout.simple_list_item_1,
newLists);
setListAdapter(myListAdapter);
}
}