Thursday, September 13, 2012

Re: [android-developers] FragmentStatePagerAdapter is not setting the UI elemtents when using Loader API

Eureka, I know What was happening was fairly trivial and makes a lots of sense, I had in my onResume() 

@Override

public void onResume() {

super.onResume();

getActivity().getSupportLoaderManager().restartLoader(CONTACT_REQUEST, null, this);

getActivity().getSupportLoaderManager().restartLoader(TRADER_DETAIL_REQUEST, null, this);

}


So this would use the supportLoader manager of the activity and since is one instance it got all my views mess up. instead I use:


getLoaderManager().restartLoader(CONTACT_REQUEST, null, this);

getLoaderManager().restartLoader(TRADER_DETAIL_REQUEST, null, this);


Which solved my problem thanks Dianne and Calin for your responses.


Sincerly yours,

[Jose Luis Ayerdis Espinoza]


2012/9/10 Jose Ayerdis <joseayerdis@gmail.com>
Interesting I'll look at it but it does not explained why the first fragment does not load the data and when I start switching this gets set. Although the listview inside each fragment get loaded and then empty.

PD. this works without a ViewPager and the FragmentStatePagerAdapter approach.

Sincerly yours,

[Jose Luis Ayerdis Espinoza]


2012/9/10 Calin Perebiceanu <calin.perebiceanu@gmail.com>
Hello,
I believe that your issue is caused by the fact that the viewpager instantiates the fragments only when needed.

You should take a look at  http://developer.android.com/reference/android/support/v4/view/ViewPager.html#setOffscreenPageLimit(int) 


On Monday, 10 September 2012 03:58:53 UTC+3, necronet wrote:
I posted in SO, probably too much code for the group. 

Tks

Sincerly yours,

[Jose Luis Ayerdis Espinoza]


2012/9/10 Dianne Hackborn <hac...@android.com>
I don't think you have provided enough information to help.  The argument you supplied to instantiate() is just made available to the fragment through Fragment.getArguments().  Presumably the problem is then somewhere in your DetailFragment and how it is managing those arguments, but you haven't provided any information about this.

On Sun, Sep 9, 2012 at 1:50 PM, Jose Ayerdis <josea...@gmail.com> wrote:
Hello everybody, so I have run now with this problem when trying to use FragmentStatePagerAdapter, I pick a specific element from a List and send an array of ids with the position picked like this

intent.putExtra("ids", ids);

intent.putExtra("position", position);


Then the activity is called which load the fragment 


        @Override

        public Fragment getItem(int i) {

         fragments[i] = DetailFragment.newInstance(tradersId[i]);

        return fragments[i];

        }


The problem is that inside the DetailFragment the values are set with the Loader API and even when they reach  onLoadFinished and set the values it never gets to be set. 

Funny thing is that once I start switching views the values are set. Any idea? Also the DetailFragment has a ListView inside which also loads with the Loader API.


Sincerly yours,

[Jose Luis Ayerdis Espinoza]

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com

To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
Dianne Hackborn
Android framework engineer
hac...@android.com


Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com

To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment