CopyPastor

Detecting plagiarism made easy.

Score: 0.8198344111442566; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2017-01-11
by Jaimin Thakkar

Original Post

Original - Posted on 2017-01-11
by Quick learner



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You need to set only one tag in putextras. Like this public void Button1(View view) { Intent intent = new Intent(view.getContext(), TabbedActivity.class); intent.putExtra("Tab", 0); //2 or whatever you want startActivity(intent); } public void Button2(View view) { Intent intent = new Intent(view.getContext(), TabbedActivity.class); intent.putExtra("Tab", 1); //2 or whatever you want startActivityForResult(intent, 0); } public void Button3(View view) { Intent intent = new Intent(view.getContext(), TabbedActivity.class); intent.putExtra("Tab", 2); //2 or whatever you want startActivityForResult(intent, 0); } public void Button4(View view) { Intent intent = new Intent(view.getContext(), TabbedActivity.class); intent.putExtra("Tab", 3); //2 or whatever you want startActivityForResult(intent, 0); } public void Button5(View view) { Intent intent = new Intent(view.getContext(), TabbedActivity.class); intent.putExtra("Tab", 4); //2 or whatever you want startActivityForResult(intent, 0); }

Then in secondactivity you need to get only one value. Like this:

final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
final int position = getIntent().getExtras().getInt("Tab");

PagerAdapter adapter = new PagerAdapter (getSupportFragmentManager(), tabLayout.getTabCount()); viewPager.setAdapter(adapter); viewPager.setCurrentItem(position);
Hope this will help you.
try this
public void Button1(View view) { Intent intent = new Intent(view.getContext(), TabbedActivity.class); intent.putExtra("tabPosition", 0); //2 or whatever you want startActivity(intent); } public void Button2(View view) { Intent intent = new Intent(view.getContext(), TabbedActivity.class); intent.putExtra("tabPosition", 1); //2 or whatever you want startActivityForResult(intent, 0); } public void Button3(View view) { Intent intent = new Intent(view.getContext(), TabbedActivity.class); intent.putExtra("tabPosition", 2); //2 or whatever you want startActivityForResult(intent, 0); } public void Button4(View view) { Intent intent = new Intent(view.getContext(), TabbedActivity.class); intent.putExtra("tabPosition", 3); //2 or whatever you want startActivityForResult(intent, 0); } public void Button5(View view) { Intent intent = new Intent(view.getContext(), TabbedActivity.class); intent.putExtra("tabPosition", 4); //2 or whatever you want startActivityForResult(intent, 0); }
Then in your view pager class
final int currentPosition = getIntent().getExtras().getInt("tabPosition");
Set your views like this
PagerAdapter adapter = new PagerAdapter (getSupportFragmentManager(), tabLayout.getTabCount()); viewPager.setAdapter(adapter); viewPager.setCurrentItem(currentPosition);


        
Present in both answers; Present only in the new answer; Present only in the old answer;