Okay, so through the help on other posts I have the ability to play a video in one app and, with the added help of this site and the fact that it references the Eclipse default SwipeView, now have another app with 4 swipe view pages.
However I cannot for the life of me find out how to make the content of each page show the text I have within the xml documents (basically, I want to combine app 1 and app 2).
It seems to come down to two parts:
[HIGH] @Override
public Fragment getItem(int position)
{
// getItem is called to instantiate the fragment for the given page.
// Return a DummySectionFragment (defined as a static inner class
// below) with the page number as its lone argument.
Fragment fragment = new DummySectionFragment();
Bundle args = new Bundle();
args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
return fragment;
}
[/HIGH]
and...
[HIGH] /**
* A dummy fragment representing a section of the app, but that simply
* displays dummy text.
*/
public static class DummySectionFragment extends Fragment
{
/**
* The fragment argument representing the section number for this
* fragment.
*/
public static final String ARG_SECTION_NUMBER = "section_number";
public DummySectionFragment() {}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.fragment_main_dummy, container, false);
TextView dummyTextView = (TextView) rootView.findViewById(R.id.section_label);
dummyTextView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));
return rootView;
}
}
[/HIGH]
The site I gave suggested a case statement:
[HIGH]
and I tried this, creating the relevant classes. However I could not get any further. The classes remain empty.
Any help? I have an xml document for each page content so all I need the select case to do is display the relevant xml document.
Oh, and shouldn't the above select case have a break within each case? Or am I missing something in this code?
However I cannot for the life of me find out how to make the content of each page show the text I have within the xml documents (basically, I want to combine app 1 and app 2).
It seems to come down to two parts:
[HIGH] @Override
public Fragment getItem(int position)
{
// getItem is called to instantiate the fragment for the given page.
// Return a DummySectionFragment (defined as a static inner class
// below) with the page number as its lone argument.
Fragment fragment = new DummySectionFragment();
Bundle args = new Bundle();
args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
return fragment;
}
[/HIGH]
and...
[HIGH] /**
* A dummy fragment representing a section of the app, but that simply
* displays dummy text.
*/
public static class DummySectionFragment extends Fragment
{
/**
* The fragment argument representing the section number for this
* fragment.
*/
public static final String ARG_SECTION_NUMBER = "section_number";
public DummySectionFragment() {}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.fragment_main_dummy, container, false);
TextView dummyTextView = (TextView) rootView.findViewById(R.id.section_label);
dummyTextView.setText(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)));
return rootView;
}
}
[/HIGH]
The site I gave suggested a case statement:
[HIGH]
- @Override
- public Fragment getItem(int position) {
- Fragment fragment = new Fragment();
- switch (position) {
- case 0:
- return fragment = new Fragment1();
- case 1:
- return fragment = new Fragment2();
- case 2:
- return fragment = new Fragment3();
- default:
- break;
- }
- return fragment;
and I tried this, creating the relevant classes. However I could not get any further. The classes remain empty.
Any help? I have an xml document for each page content so all I need the select case to do is display the relevant xml document.
Oh, and shouldn't the above select case have a break within each case? Or am I missing something in this code?