I have a fragment in which I want to have a main ImageButton in the center and 2 FAB's on either side that would go to the previous or next Image respectively. I have this set up in XML but can't quite figure out how to make it all fit in Java.
public class NewCard extends Fragment {
public static int cardNumber;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_new_card, container, false);
final ImageButton button = view.findViewById(R.id.card1);
FloatingActionButton previous = view.findViewById(R.id.previous);
FloatingActionButton next = view.findViewById(R.id.next);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
cardNumber = 1;
FinalSubmit fragment = new FinalSubmit();
getContext().getSharedPreferences("pref", 0).edit().putInt("int", cardNumber).apply();
address fragment4 = new address();
FragmentTransaction ft4 = getFragmentManager().beginTransaction();
ft4.replace(R.id.frameLayout, fragment4, "FragmentName");
ft4.commit();
}});
return view;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}