I need to create four different layouts, each one to a page of ViewPagerIndicator. How can I do this? The ViewPagerIndicator is already working, but I'm using the sample from http://viewpagerindicator.com and there is created a simple TextView for all pages.
See the sample (TestFragment.java):
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
TextView text = new TextView(getActivity());
text.setGravity(Gravity.CENTER);
text.setText(mContent);
text.setTextSize(20 * getResources().getDisplayMetrics().density);
text.setPadding(20, 20, 20, 20);
LinearLayout layout = new LinearLayout(getActivity());
layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
layout.setGravity(Gravity.CENTER);
layout.addView(text);
return layout;
}
I need to identify the current page (position) and refer to a related resource layout (XML). Is it possible?
I also need to ensure that all Views of all pages to be loaded at once only one time when I create the activity, allowing values to be updated later.
I appreciate any help!! Thanks
I found a simple solution which works for me. Here is what I did.
TestFragment.class
Comment out the for loop here. Just get the mContent which we are going to use as a Flag.
Now in your
onCreateView()
change it as follows,That is all it takes. Now you will be able to inflate your views based on the Title name which we have used as the flag.