recyclerView.addOnItemTouchListener(new GalleryAdapter.RecyclerTouchListener(getApplicationContext(), recyclerView, new GalleryAdapter.ClickListener() {
@Override
public void onClick(View view, int position) {
Bundle bundle = new Bundle();
bundle.putSerializable("images", images);
bundle.putInt("position", position);
SlideshowDialogFragment newFragment = SlideshowDialogFragment.newInstance();
FragmentTransaction ft = getSupportFragmentManager()
.beginTransaction();
newFragment.setArguments(bundle);
newFragment.show(ft, "slideshow");
}
@Override
public void onLongClick(View view, int position) {
Toast.makeText(MainActivity.this, "long click" ,
Toast.LENGTH_SHORT).show();
}
}
));
Asked
Active
Viewed 80 times
0

craigcaulfield
- 3,381
- 10
- 32
- 40

Firmansyah
- 21
- 3
1 Answers
0
You should refer to the method I have used -
@Override
public void switchFragment(@Nullable android.app.Fragment targetFragment, @Nullable boolean addToBackStack, Bundle bundle, @Nullable String fragmentTag) {
android.app.FragmentManager fragmentManager = getFragmentManager();
android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if (addToBackStack) {
fragmentTransaction.addToBackStack(fragmentTag);
}
if (bundle != null) {
targetFragment.setArguments(bundle);
}
fragmentTransaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right);
fragmentTransaction.replace(R.id.container, targetFragment);
fragmentTransaction.commit();
}
and put the anim files in your anim folder-
enter_from_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="-100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="300"/>
</set>
enter_from_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="300" />
</set>
exit_to_left.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="0%" android:toXDelta="-100%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="300"/>
</set>
exit_to_right.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="0%" android:toXDelta="100%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="300" />
</set>

Rohit Sharma
- 1,384
- 12
- 19