android-fragments

DialogFragment callback to Target Fragment using interface

邮差的信 提交于 2020-08-24 08:27:12
问题 I am trying to send some data from a dialogfragment to the targeted fragment but its not working. I have written the following code, but it through exception : java.lang.NullPointerException: Attempt to invoke interface method 'void com.x.x.FragmentAlertDialog$Communicator.setI(java.lang.String)' on a null object reference Code: public class FragmentAlertDialog extends DialogFragment { Communicator callback; public interface Communicator { void setI(String name); } public static

Disable swipe in fragmentPagerAdapter? - android

南楼画角 提交于 2020-08-24 06:38:34
问题 Hey guys i have a fragmentPagerAdapter with 3 fragments in it. How would i disable the swiping between the 3 fragments so the user only uses the tabview to go between fragments? Cheers! private class ViewPagerAdapter extends FragmentPagerAdapter { ArrayList<Fragment> fragments = new ArrayList<>(); ArrayList<String> tabTitles = new ArrayList<>(); public ViewPagerAdapter(android.support.v4.app.FragmentManager fragmentManager) { super(fragmentManager); } @Override public Fragment getItem(int

Can't remove space on top of nav_host_fragment

Deadly 提交于 2020-08-22 09:21:27
问题 I just implemented a bottom navigation (AS's default - File -> New -> Activity -> Bottom Navigation Activity) Everything is fine except for a space on the top of the nav_host_fragment . Since it was generated in a ConstraintLayout, I tried to clean the constraints and set the top constraint with parent , setting margin to '0dp' and set height to match_constraint . I unsuccessfully deleted the constraints and tried over and over again. I used Clean Project . I changed to RelativeLayout and set