How Can I Use A Button To Open An Xml File In My Project
I want to open an xml file in my project on button click this is my code could somebody please suggest me how can i do it. I'm unable to do it the one i did was using onclicklisten
Solution 1:
FragmentB fragmentB = new FragmentB();
FragmentManager manager = getSupportFragmentManager();
manager.beginTransaction().replace(R.id.fragment, customerFragment).commit();
write this in your onClick method for navigating from FragmentA to navigate to FragmentB.
Solution 2:
You have FragmentFirstPage and FragmentSecondPage, you may have fragment_page1.xml and fragment_page2.xml
PS: remove any android:onClick attribute
Inside your FirstFragmentPage, on onCreateView (), , add the following if your button is on fragment_page1.xml
Button bt = (Button) root.findViewById(R.id.your_button_id);
ViewPager viewPager = (ViewPager) getActivity().findViewById (R.id.your_viewpager_id ();
bt.setOnClickListener(new View.onClickListener (){
@Override
public void onClick (View v){
viewPager.setCurrentItem (viewPager.getCurrentItem() + 1); //or -1 to go previous
}
}
Forgive my code format, I'm typing from my smartphone : /
Post a Comment for "How Can I Use A Button To Open An Xml File In My Project"