Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 994
Deep Singh Avatar asked Dec 02 '22 17:12

Deep Singh


1 Answers

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.

like image 90
Skynet Avatar answered Dec 05 '22 05:12

Skynet