I can not figure out how to transfer the position of a line to a fragment. I need the fragment to get the number of the selected line

public class TabAdapter extends FragmentPagerAdapter { public static final String[] TITLES = {"текст1","текст1", "текст1", "текст1", "текст1"}; public InformTabAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { Log.i(String.valueOf(position), "Что тут у нас 0 да?"); InfoTabFragment tabFragment = new InfoTabFragment(); Bundle b = new Bundle(); b.putInt("position", position); tabFragment.setArguments(b); return tabFragment; } @Override public int getCount() { return TITLES.length; } @Override public CharSequence getPageTitle(int position) { return TITLES[position]; } 

}

I write int x = getArguments (). getInt ("position"); he crash

Closed due to the fact that off-topic participants YuriySPb , katso , aleksandr barakin , cheops , Streletz 25 May '16 at 9:33 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - YuriyPb, katso, aleksandr barakin, cheops, Streletz
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Why do I get the text and not the position, write how to get the number - djo
  • Please attach the error log - xkor
  • that's all, I called int x = getArguments (). getInt ("position") not there; ( - djo

0