Search code examples
androidfragment

How to move from a one fragment to an activity


I am working on a CustomListView for a fragment and CustomAdapter extends from BaseAdapter . In my CustomAdapter there is button on click that button i want to move a activity but i don't know how to switch from one fragment to an activity.


Solution

  • Try this:

    private void moveToNewActivity () {
    
        Intent i = new Intent(getActivity(), DetailActivity.class);
        startActivity(i);
        ((Activity) getActivity()).overridePendingTransition(0, 0);
    
    }
    

    overridePendingTransition(0,0); means no Animation in transition.

    Check This, it will give you a fair idea of how an onClickListener is used to start a new Activity, from within a Fragment.