Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ContactsFragment extends Fragment {
- public ContactsFragment() {
- // Required empty public constructor
- }
- public static final String[] titles = new String[] { "Item 1",
- "Item 2", "Item 3", "Item 4",
- "Item 5", "Item 6", "Item 7", "Item 8",
- "Item 9", "Item 10", "Item 11", "Item 12",
- "Item 13", "Item 14", "Item 15",
- "Item 16", "Item 17", "Item 18"};
- ListView listView;
- List<ItemPippo> rowItems;
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_contacts, container, false);
- rowItems = new ArrayList<ItemPippo>();
- for (int i = 0; i < titles.length; i++) {
- ItemPippo item = new ItemPippo(titles[i]);
- rowItems.add(item);
- }
- listView = (ListView) view.findViewById(R.id.listview_contacts);
- CustomListViewAdapter adapter = new CustomListViewAdapter(getActivity(),
- R.layout.layout_project_sicily, rowItems);
- listView.setAdapter(adapter);
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- switch (position) {
- case 0:
- break;
- case 1:
- break;
- case 2:
- break;
- case 16:
- FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
- fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
- fragmentTransaction.replace(R.id.frame, new ItemSediciFragment());
- fragmentTransaction.addToBackStack(null);
- fragmentTransaction.commit();
- break;
- }
- }
- });
- return view;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement