There is a ViewPager which is disabled scrolling. I want to click on the ViewPager go to the next page.
here is my fragment:
public SelectFragment() { } public static SelectFragment newInstance(int sectionNumber, int id) { SelectFragment fragment = new SelectFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); args.putInt("idGroup", id); fragment.setArguments(args); return fragment; } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_select, container, false); pager = (ViewPager) rootView.findViewById(); String id = getString(R.string.kalima, getArguments().getInt("idGroup")); String page = getString(R.string.kalima, getArguments().getInt(ARG_SECTION_NUMBER)); textView = (TextView) rootView.findViewById(R.id.textSelect); imageone = (Button) rootView.findViewById(R.id.buttonSelectOne); imagetwo = (Button) rootView.findViewById(R.id.buttonSelecttwo); imageone.setOnClickListener(this); imagetwo.setOnClickListener(this); _select = DataServer.getSelectData(Integer.parseInt(id),getActivity()); textView.setText(_select.get(Integer.parseInt(page)).getKalima()); imageselect.setImageResource(R.mipmap.animation_img1); } return rootView; } @Override public void onClick(View v) { Button button = (Button) v; String s = button.getText().toString(); String t = textView.getTag().toString(); if (s.equals(t)) { pager.setCurrentItem(1); } } adapter code:
public class KalimaPagerAdapter extends FragmentPagerAdapter { private int idGroup; public KalimaPagerAdapter(FragmentManager fm, int id) { super(fm); idGroup = id; } @Override public Fragment getItem(int position) { return SelectFragment.newInstance(position, idGroup); } @Override public int getCount() { return 5; }
pager.setCurrentItem(pager.getCurrentItem() + 1)should work. With verification of boundary values, of course. - Eugene Krivenjapagerregistered. - Jarvis_J 3:49 pm