Advertisement
jumpy83

Contacts fragment

Jun 15th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1.  
  2. public class ContactsFragment extends Fragment {
  3.  
  4.  
  5. public ContactsFragment() {
  6. // Required empty public constructor
  7. }
  8.  
  9. public static final String[] titles = new String[] { "Item 1",
  10. "Item 2", "Item 3", "Item 4",
  11. "Item 5", "Item 6", "Item 7", "Item 8",
  12. "Item 9", "Item 10", "Item 11", "Item 12",
  13. "Item 13", "Item 14", "Item 15",
  14. "Item 16", "Item 17", "Item 18"};
  15.  
  16.  
  17.  
  18. ListView listView;
  19. List<ItemPippo> rowItems;
  20.  
  21. @Override
  22. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  23. View view = inflater.inflate(R.layout.fragment_contacts, container, false);
  24.  
  25. rowItems = new ArrayList<ItemPippo>();
  26. for (int i = 0; i < titles.length; i++) {
  27. ItemPippo item = new ItemPippo(titles[i]);
  28. rowItems.add(item);
  29. }
  30.  
  31. listView = (ListView) view.findViewById(R.id.listview_contacts);
  32. CustomListViewAdapter adapter = new CustomListViewAdapter(getActivity(),
  33. R.layout.layout_project_sicily, rowItems);
  34. listView.setAdapter(adapter);
  35. listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  36. public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  37. switch (position) {
  38. case 0:
  39. break;
  40. case 1:
  41. break;
  42. case 2:
  43. break;
  44. case 16:
  45. FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
  46. fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
  47. fragmentTransaction.replace(R.id.frame, new ItemSediciFragment());
  48. fragmentTransaction.addToBackStack(null);
  49. fragmentTransaction.commit();
  50. break;
  51. }
  52. }
  53. });
  54.  
  55. return view;
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement