0

Can you help me with this problem. I am learning Android so not Idea what happens.. image link error

The problem in the last line of code: customEmpDialogFragment.show(this.getFragmentManager(), CustomEmpDialogFragment.ARG_ITEM_ID);

Hope you can help me.

public class EmpListFragment extends Fragment implements AdapterView.OnItemClickListener,
    AdapterView.OnItemLongClickListener {

        public static final String ARG_ITEM_ID = "employee_list";

        Activity activity;
        ListView employeeListView;
        ArrayList < Employee > employees;

        EmpListAdapter employeeListAdapter;
        EmployeeDAO employeeDAO;

        private GetEmpTask task;

        @
        Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            activity = getActivity();
            employeeDAO = new EmployeeDAO(activity);
        }

        @
        Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.activity_emp_list_fragment, container,
                false);
            findViewsById(view);

            task = new GetEmpTask(activity);
            task.execute((Void) null);

            employeeListView.setOnItemClickListener(this);
            employeeListView.setOnItemLongClickListener(this);
            // Employee e = employeeDAO.getEmployee(1);
            // Log.d("employee e", e.toString());
            return view;
        }

        private void findViewsById(View view) {
            employeeListView = (ListView) view.findViewById(R.id.list_emp);
        }

        @
        Override
        public void onResume() {
            getActivity().setTitle(R.string.app_name);
            getActivity().getActionBar().setTitle(R.string.app_name);
            super.onResume();
        }

        @
        Override
        public void onItemClick(AdapterView <? > list, View arg1, int position,
            long arg3) {
            Employee employee = (Employee) list.getItemAtPosition(position);

            if (employee != null) {
                Bundle arguments = new Bundle();
                arguments.putParcelable("selectedEmployee", employee);
                CustomEmpDialogFragment customEmpDialogFragment = new CustomEmpDialogFragment();
                customEmpDialogFragment.setArguments(arguments);
                customEmpDialogFragment.show(this.getFragmentManager(), CustomEmpDialogFragment.ARG_ITEM_ID);


            }
        }

    }
robto09
  • 193
  • 2
  • 12

1 Answers1

0

I didn't see your logcat, i assume you are having problem showing your fragment. Try this.

Bundle arguments = new Bundle();
            arguments.putParcelable("selectedEmployee", employee);
            CustomEmpDialogFragment customEmpDialogFragment = new CustomEmpDialogFragment();
            customEmpDialogFragment.setArguments(arguments);
addFragment(R.id.fl_home_container, fragment, "Fragment1");  



public void addFragment(int container, Fragment fragment, String tag) {
        FragmentActivity activity = getActivity();
        if (activity != null && !activity.isFinishing()) {
            getActivity().getSupportFragmentManager().beginTransaction().add(container, fragment, tag).addToBackStack(tag).commit();
        }
    }
kggoh
  • 742
  • 1
  • 10
  • 24