Android ViewPager inside Layoutinflator - android

I build a project. but I'm having problems.
My project has page A , Page B
from Picture http://s20.postimg.org/5pupjbuyl/untitled.png
Page A is FrameLayout (id=layout) , in FrameLayout has LinearLayout and FrameLayout (id=content)
Page B is FrameLayout (id=pager) , in FrameLayout has Viewpager
I would take Framelayout (id=content) in page A containing FrameLayout(id = pager) in page B
(Notice : I try to minimize my code because It many line)
PageIndicatorActivity .java
public class PageIndicatorActivity extends Activity {
...
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
..
..
ViewGroup Content = (ViewGroup)findViewById(R.id.layout);
ViewBookAdapter pager = new ViewBookAdapter(this);
Content.addView(pager.getView());
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main,menu);
return true;
}}
pager.java
public class Pager extends PagerAdapter {
Activity activity;
private static String content[] = {"file:///android_asset/html/page1.html","file:///android_asset/html/page2.html"};
public Pager(Activity act) {
activity = act;
}
public int getCount() {
return content.length;
}
public Object instantiateItem(View collection, int position) {
WebView view = new WebView(activity);
view.loadUrl(content[position]);
view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
((ViewPager) collection).addView(view, 0);
return view;
}
#Override
public void destroyItem(View arg0, int arg1, Object arg2) {
((ViewPager) arg0).removeView((View) arg2);
}
#Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == ((View) arg1);
}
#Override
public Parcelable saveState() {
return null;
}}
and ViewBookAdapter.java
class ViewBookAdapter {
Activity activity;
private LayoutInflater minflate;
private ViewPager myPager;
public ViewBookAdapter(Activity act){
activity = act;
myPager = (ViewPager)act.findViewById(R.id.viewPager);
Pager p = new Pager(act);
myPager.setAdapter(p); // <--- THIS PROBLEM ---
}
public View getView(){
LayoutInflater minflate = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = minflate.inflate(R.layout.pager, null);
return v;
}}
I have a probleam at myPager.setAdapter(p);
Android Report Bug is NullPointerException
How to solve?
THANK YOU FOR ANSWER ^^
PS. sorry english .

This is happening because your Activity does not have the ViewPager in its layout. Its in the other layout. You will need to do setAdapter in getView()

Your current PageIndicatorActivity layout does not have a ViewPager. If you need to continue this way you have to move to Activity(Page B) and follow your implementation.

Related

What is the best place to retrive ViewPager child's layout?

Good morning,
I have a Fragment which its layout has a ViewPager, I provide a custom PageAdapter to show two child layouts. One layout is to fill with personal data and another layout is to fill with Address data by the user. On my fragment I want to retrieve both layouts data and fill a object Pessoa(Person) with an attribute Endereco (Address). So far my ViewPager is working and both layout are displayed, however when I try to get the fields on both layouts, either on onCreateView or onResume fragment's method, using :
viewpager.getChildAt(0).findViewById(R.id.txt1)
I got an NullPointerException, but if I add an OnPageChangeListener this works, I not sure if it's the best approach. Is There a best place to retrieve a reference to the viewpager child's layout?
Ps. I don't want to use two other Fragments in order to display each of the layouts.
PageAdapter
public class ViewPagerCadastroPessoaAdapter extends PagerAdapter {
private Context context;
private int[] views = {R.layout.layout_cadastro_dados_pessoais,R.layout.layout_cadastro_endereco };
public ViewPagerCadastroPessoaAdapter(Context context) {
this.context = context;
}
#Override
public Object instantiateItem(ViewGroup container, int position) {
LayoutInflater inflater = LayoutInflater.from(this.context);
View layout = inflater.inflate(views[position], container, false);
container.addView(layout, position);
return layout;
}
#Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
#Override
public int getCount() {
return 2;
}
#Override
public CharSequence getPageTitle(int position) {
switch (position){
case 0:
return "Dados Pessoais";
case 1:
return "Endereço";
}
return super.getPageTitle(position);
}
#Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}}
ViewPager's holder Fragment
public class CadastroPessoaFragment extends Fragment {
private ViewPager viewPagerCadastroPessoa;
private TabLayout tabLayoutCadastroPessoa;
public CadastroPessoaFragment() {
}
public static CadastroPessoaFragment newInstance() {
return new CadastroPessoaFragment();
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_cadastro_pessoa, container, false);
tabLayoutCadastroPessoa = root.findViewById(R.id.tabLayoutCadastroPessoa);
viewPagerCadastroPessoa = root.findViewById(R.id.viewPagerCadastroPessoa);
viewPagerCadastroPessoa.setOffscreenPageLimit(2);
viewPagerCadastroPessoa.setAdapter(new ViewPagerCadastroPessoaAdapter(getContext()));
tabLayoutCadastroPessoa.setupWithViewPager(viewPagerCadastroPessoa);
int cor = ContextCompat.getColor(getContext(), android.R.color.white);
tabLayoutCadastroPessoa.setTabTextColors(cor, cor);
//get a null pointer
viewPagerCadastroPessoa.getChildAt(0).findViewById(R.id.txt1);
viewPagerCadastroPessoa.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
#Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
#Override
public void onPageSelected(int position) {
//works fine
viewPagerCadastroPessoa.getChildAt(0).findViewById(R.id.txt1);
}
#Override
public void onPageScrollStateChanged(int state) {
}
});
return root;
}
#Override
public void onResume() {
super.onResume();
//get a null pointer
viewPagerCadastroPessoa.getChildAt(0).findViewById(R.id.txt1);
}
}
Thank you all in advance
UPDATE
According with
Anton Malyshev answer
The way Viewpager creates its pages is kind of "unsynchronized", so I used the following approach to solve my problem:
On my custom adapter I definied an interface with a single method onViewPagerReady(), as my Viewpager will always have only two pages, inside instantiateItem I check when position is 1 (once position starts with 0), if position == 1 I call the method onViewPagerReady that my fragment viewpager's holder implements, so inside this method I retrieve the layout of viewpager's children
public class ViewPagerCadastroPessoaAdapter extends PagerAdapter {
public interface ViewPagerObserver{
void onViewPagerReady();
}
private Context context;
private int[] views = {R.layout.layout_cadastro_dados_pessoais,R.layout.layout_cadastro_endereco };
private ViewPagerObserver observer;
public ViewPagerCadastroPessoaAdapter(Context context, ViewPagerObserver observer) {
this.context = context;
this.observer = observer;
}
#Override
public Object instantiateItem(ViewGroup container, int position) {
LayoutInflater inflater = LayoutInflater.from(this.context);
View layout = inflater.inflate(views[position], container, false);
container.addView(layout, position);
if(position == 1){
observer.onViewPagerReady();
}
return layout;
}
#Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
#Override
public int getCount() {
return 2;
}
#Override
public CharSequence getPageTitle(int position) {
switch (position){
case 0:
return "Dados Pessoais";
case 1:
return "Endereço";
}
return super.getPageTitle(position);
}
#Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
}
Fragment Viewpager's Holder
#Override
public void onViewPagerReady() {
View rootCadastroDadosPessoais = viewPagerCadastroPessoa.getChildAt(0);
View rootCadastroEnderecos =viewPagerCadastroPessoa.getChildAt(1);
}
Thank you all.
Just wait until viewPagerCadastroPessoa.getChildCount() will be greater than 0. The pages in ViewPager are not created yet in onResume (they are created asynchronously).

Android ViewPager PagerAdapter contents without calling PagerAdapter#notifyDataSetChanged Exception

I have a ViewPager in my activity. The ViewPager shows different values on swiping the pager. But I get an IllegalStateException:
PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged!
Expected adapter item count: 0, found: 20
Pager id: com.exalt.vts:id/summarypager Pager class: class android.support.v4.view.ViewPager
Problematic adapter: class com.exalt.vts.DashBoard$MyPagerAdapter
This is my source code for PagerAdapter:
public class SamplePagerAdapter extends PagerAdapter{
List<View> pages = null;
public SamplePagerAdapter(List<View> pages){
this.pages = pages;
}
#Override
public Object instantiateItem(View collection, int position){
View v = pages.get(position);
((ViewPager) collection).addView(v, 0);
return v;
}
#Override
public void destroyItem(View collection, int position, Object view){
((ViewPager) collection).removeView((View) view);
}
#Override
public int getCount(){
return pages.size();
}
#Override
public boolean isViewFromObject(View view, Object object){
return view.equals(object);
}
#Override
public void finishUpdate(View arg0){
}
#Override
public void restoreState(Parcelable arg0, ClassLoader arg1){
}
#Override
public Parcelable saveState(){
return null;
}
#Override
public void startUpdate(View arg0){
}
}
This is the MainActivity:
public class MainActivity extends Activity {
ViewPager viewPager;
SamplePagerAdapter myPagerAdapter;
private TextView textView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
List<View> pages = new ArrayList<View>();
viewPager = (ViewPager)findViewById(R.id.myviewpager);
myPagerAdapter = new SamplePagerAdapter(pages);
viewPager.setAdapter(myPagerAdapter);
viewPager.setCurrentItem(1);
LayoutInflater inflater = LayoutInflater.from(this);
View page = inflater.inflate(R.layout.mylayout, null);
for (int i = 0; i < 20; i++) {
page = inflater.inflate(R.layout.mylayout, null);
textView = (TextView) page.findViewById(R.id.text_view);
textView.setText("Страница "+i);
pages.add(page);
}
}
I try to add 20 views in my ViewPager but I get an exception.
You either need to move the following code from where it is currently to after your for loop, so that the adapter is set after your data set is setup
myPagerAdapter = new SamplePagerAdapter(pages);
viewPager.setAdapter(myPagerAdapter);
viewPager.setCurrentItem(1);
or alternatively, you can add the following after your for loop to notify the adapter that the data set has changed since you set it up
myPagerAdapter.notifyDataSetChanged();

How to update currentview of viewPager?

I need to change the size of all views on toggle. I did it but the
textsize got changed only from 3rd view. The first and second got
unchanged. Please suggest to update all the views.
public class MainActivity extends Activity {
ViewPager viewPager;
public static ArrayList<NewsItem> newslist;
public static PagerAdapter adapter;
public static ProgressDialog progressDialog;
LayoutInflater inflater;
public static float fntSize=30;
private ToggleButton togButton1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
newslist = new ArrayList<NewsItem>();
adapter = new ViewPagerAdapter(getApplicationContext(), newslist);
viewPager = (ViewPager) findViewById(R.id.pager);
viewPager.setAdapter(adapter);
addMainButtonListener();
loadNews();
}
public void addMainButtonListener() {
togButton1 = (ToggleButton) findViewById(R.id.toggleButton1);
togButton1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
fntSize=50;
} else {
fntSize=30;
}
}
});
#Override
public boolean onCreateOptionsMenu(Menu menu) {
new MenuInflater(this).inflate(R.menu.activity_main, menu);
return (super.onCreateOptionsMenu(menu));
}
private void loadNews(){
progressDialog= ProgressDialog.show(this,"Progress Dialog Title Text","Process Description Text");
News news = new News(getApplicationContext());
news.execute();
viewPager.setCurrentItem(0);
}
}
And My ViewPager class is
public class ViewPagerAdapter extends PagerAdapter {
// Declare Variables
Context context;
ArrayList<NewsItem> newslist = new ArrayList<NewsItem>();
LayoutInflater inflater;
public TextView txtNewsDesc;
public ViewPagerAdapter(Context context, ArrayList<NewsItem> newslist) {
this.context = context;
this.newslist = newslist;
}
#Override
public int getCount() {
return this.newslist.size();
}
#Override
public boolean isViewFromObject(View view, Object object) {
return view == ((RelativeLayout) object);
}
#Override
public Object instantiateItem(ViewGroup container, int position) {
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.news_item, container,
false);
txtNewsDesc = (TextView) itemView.findViewById(R.id.news_desc);
NewsItem news = this.newslist.get(position);
txtNewsDesc.setTextSize(MainActivity.fntSize);
txtNewsDesc.setText(news.getDesc());
// Add viewpager_item.xml to ViewPager
Typeface typeFace = Typeface.createFromAsset(context.getAssets(), "fonts/preeti.ttf");
txtNewsDesc.setTypeface(typeFace);
((ViewPager) container).addView(itemView);
return itemView;
}
#Override
public void destroyItem(ViewGroup container, int position, Object object) {
// Remove viewpager_item.xml from ViewPager
((ViewPager) container).removeView((RelativeLayout) object);
}
}
I know the first is not changed since it is not reloaded but what about 2nd view? Please help to change the text size of all the views on toggle button click.
The ViewPager creates and retains another page beside the current one and that demonstrates why the second stay the same.
To achieve what you want you need to update the size manually when the toggle button clicked, you can keep a reference to the current view in the ViewPagerAdapter and create a method to return that view as follow
public TextView getCurrentView(){
return txtNewsDesc;
}
Then in addMainButtonListener method get the current view using the method you have created and update the text size
togButton1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if (isChecked) {
fntSize=50;
} else {
fntSize=30;
}
((ViewPagerAdapter)viewPager).getCurrentView().setTextSize(fntSize);
}
You should use
public int getItemPosition(Object object) {
return POSITION_NONE;
}
use setTag() in instantiateItem() and instead of called notifyDataSetChanged() use findViewWithTag() and update tour text size.
For see this and in this thread https://stackoverflow.com/a/8024557
i found solution
crerate interface RefreshFragment
public interface RefreshFragment{void refresh();}
in the fragment which is pager item implement RefreshFragment
and at the class where you create the pager adapter do the folowing
circlePageIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
#Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
#Override
public void onPageSelected(int position) {
((RefreshFragment) pagerAdapter.getItem(position)).refresh();
}
#Override
public void onPageScrollStateChanged(int state) {
}
});
i hope this is your solution

Load webview into viewpager by replacing imageview in the view pager

i am implementing an app in which i firstly load images into viewpager. I need to replace the images and get webview after it loads completely. how can i do it.
My viewpager code is as follows:
public class HtmlPagerAdapter extends PagerAdapter {
private ArrayList<LinearLayout> views;
Context con;
public HtmlPagerAdapter(Context context, ArrayList<LinearLayout> filelist) {
this.con = context;
views = new ArrayList<LinearLayout>();
this.views = filelist;
}
#Override
public void destroyItem(View view, int arg1, Object object) {
((ViewPager) view).removeView((LinearLayout) object);
}
#Override
public void finishUpdate(View arg0) {
}
#Override
public int getCount() {
return views.size();
}
#Override
public Object instantiateItem(View view, int position) {
View myView = views.get(position);
((ViewPager) view).addView(myView);
return myView;
}
#Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
#Override
public void restoreState(Parcelable arg0, ClassLoader arg1) {
}
#Override
public Parcelable saveState() {
return null;
}
#Override
public void startUpdate(View arg0) {
}
}
my imageview creation code is as like as follows:
for(int t=0;t<list.length;t++){
ImageView img=new ImageView(con); // con is context
img.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
line = new LinearLayout(con);
img.setBackgroundResource(drawable.bg_downissue);
line.addView(img);
filelist.add(line); //filelist is arraylist<linearlayout>
}
adapter = new HtmlPagerAdapter(con, filelist);
viewPager.setAdapter(adapter);
My webview creation is also a dynamic webview like
for(int t=0;t<list.length;t++){
WebView web=new WebView(this);
web.loadDataWithBaseURL(myUrl);
}
i want to place this webview into the imageview in viewpager. Please help me. I am really stuck on this part.
I would suggest you to change quite a bit of those code:
change the ImageView and WebView creation to a XML layout, put both inside a FrameLayout with match_parent.
On the WebView you'll attach a WebViewClient and override the onPageFinished to know when the page finished loading.
Then it's just a matter of inflating the XML and make the WebView invisible; then whenever the WebViewClient notifies that it finished loading you set the WebView visible and the ImageView invisible.

Android: Horizontal View Pager not on the main screen

I recently have started programming again for the android and am currently working on a app that I would like to implement horizontal view pagers so the user in one instance can swipe between two pages to enter/update information and in a later instance swipe between four pages to view information that they have entered/updated. I am basically making an electronic character sheet for roleplaying games.
I have been working off of these tutorials for horizontal view pagers:
http://mobile.tutsplus.com/tutorials/android/android-user-interface-design-horizontal-view-paging/
http://manishkpr.webheavens.com/android-viewpager-example/
My question is of all the tutorials I have seen, the h. view pager is used off of the main activity screen, is there a way to implement the horizontal view pager off of a subsequent screen? Every time I have tried to implement the code to work off of a page other than a main screen it has crashed as soon as I got to that page.
So, long story short, has anyone successfully implemented horizontal view pagers on a non main page and if so, how?
I hope that I have made sense, but if you have any further questions please let me know!
08-24 01:44:34.310: I/ActivityManager(144): START {cmp=com.echaractersheet/.CharacterStats1} from pid 15115
08-24 01:44:34.360: D/AndroidRuntime(15115): Shutting down VM
08-24 01:44:34.360: W/dalvikvm(15115): threadid=1: thread exiting with uncaught exception (group=0x40a581f8)
08-24 01:44:34.370: E/AndroidRuntime(15115): FATAL EXCEPTION: main
08-24 01:44:34.370: E/AndroidRuntime(15115): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.echaractersheet/com.echaractersheet.CharacterStats1}: java.lang.NullPointerException
characterstats.xml:
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/characterstatspager" />
characterstats1.xml and characterstats2.xml are the two pages I want to swipe between
CharacterStatsPagerAdapter.java:
...
public class CharacterStatsPagerAdapter extends PagerAdapter {
public int getCount() {
return 2;
}
public Object instantiateItem(View collection, int position) {
LayoutInflater inflater = (LayoutInflater) collection.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
int resId =0;
switch (position) {
case 0:
resId = R.layout.characterstats1;
break;
case 1:
resId = R.layout.characterstats2;
break;
}
View view = inflater.inflate(resId, null);
((ViewPager) collection).addView(view, 0);
return view;
}
#Override
public void destroyItem(View arg0, int arg1, Object arg2) {
((ViewPager) arg0).removeView((View) arg2);
}
#Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == ((View) arg1);
}
#Override
public Parcelable saveState() {
return null;
}
}
CharacterStats1.java:
CharacterStatsPagerAdapter adapter = new CharacterStatsPagerAdapter();
ViewPager myPager = (ViewPager) findViewById(R.id.characterstatspager);
myPager.setAdapter(adapter);
myPager.setCurrentItem(0);
well the pager will work with the data in the adapter, so as long as you keep the objects in the adapter, you are good to go. so maybe before going to the next screen you should save the objects in the adapter (maybe to a static field in another class, just for a moment) and when you get to the new page you can retrieve the objects and put them in the adapter of the new viewpager and add the new pages. That is what i will do in your case.
UPDATE:
this is just an example, this needs more lines of code, but is a good start.
public class Fields {
private String name;
private String lastName;
private int age;
private boolean male;
public Fields(){
this.name = "";
this.lastName = "";
}
public Fields(String name, String lastName, int age, boolean male) {
this.name = name;
this.lastName = lastName;
this.age = age;
this.male = male;
}
public View getRepresentation(Context mContext){
/*Create the view that ViewPager will display*/
LinearLayout layout = new LinearLayout(mContext);
layout.addView(new TextView(mContext)); //Name
layout.addView(new TextView(mContext)); //LastName
layout.addView(new TextView(mContext)); //Age
layout.addView(new CheckBox(mContext)); //Male/Female
return layout;
}
}
The View Pager Adapter
public class ViewPagerAdapter extends PagerAdapter {
private List<Fields> pages;
private Context mContext;
public ViewPagerAdapter( Context mContext )
{
this.mContext = mContext;
}
public void setPages(List<Fields> pages){
this.pages = pages;
}
public List<Fields> getPages(){
return this.pages;
}
#Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
#Override
public int getCount()
{
return pages.size();
}
#Override
public Object instantiateItem( View pager, int position )
{
View view = pages.get(position).getRepresentation(mContext);
view.setId(position);
return view;
}
#Override
public void destroyItem( View pager, int position, Object view )
{
((ViewPager)pager).removeViewInLayout( (View) view );
}
#Override
public boolean isViewFromObject( View view, Object object )
{
return view.equals( object );
}
}
Main Class
public class MainActivity extends Activity {
private Context mContext;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.mContext = getApplicationContext();
setContentView(R.layout.viewpager_layout);
final List<Fields> fields = new ArrayList<Fields>();
fields.add(new Fields());
ViewPager mPager = (ViewPager) this.findViewById(R.id.viewpager);
Button nextActivity = (Button) this.findViewById(R.id.nextAct);
ViewPagerAdapter mAdapter = new ViewPagerAdapter(mContext);
mAdapter.setPages(fields);
mPager.setAdapter(mAdapter);
nextActivity.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
SecondActivity.pages = fields;
Intent intent = new Intent(mContext, SecondActivity.class);
startActivity(intent);
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Second Class
public class SecondActivity extends Activity {
public static List<Fields> pages;
private Context mContext;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.mContext = getApplicationContext();
setContentView(R.layout.viewpager_layout);
final List<Fields> fields = pages;
pages = null;
fields.add(new Fields()); //Add the new Pages
ViewPager mPager = (ViewPager) this.findViewById(R.id.viewpager);
Button nextActivity = (Button) this.findViewById(R.id.nextAct);
ViewPagerAdapter mAdapter = new ViewPagerAdapter(mContext);
mAdapter.setPages(fields);
mPager.setAdapter(mAdapter);
nextActivity.setVisibility(View.GONE);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
As i said, this is JUST AN EXAMPLE, the Fields Class should be changed for your Objects, the ViewPagerAdapter is where you keep the list of pages that you will pass to the next activity.
And the static field on the secondactivity is just to be use as a bridge between activities and
should not be overuse, thats is why after fetching the data you need to set to NULL to know that you
already grabbed the value. Hope it helps.
NOTE: THIS CODE WILL NOT WORK AS IT IS, need more code.

Categories

Resources