Start another Fragment on click from a list in listfragment
I am able to start another fragment using on item selected from list
fragment. In second fragment i have a list view which I want only to be
displayed when list item is clicked from first fragment. But I am getting
the list view items in second fragment as soon as I start the activity.
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);
}
}
No comments:
Post a Comment