1

Is there any way that you can call a function after its getView method has been called. For example, i would like to be able to hide/show various widgets based on the size of them. For this i need to be able to query the size of the widget in the view.

My problem is that the getView method in an overwritten ArrayAdapter does not actually inflate the view so that any getWidth/getLeft/getHeight etc calls on widgets inside the View come back as 0. I was wondering, is there a way to call a function after that waits until the view has been properly inflated? Or perhaps an event binding that can be done that in effect waits until the view is fully inflated in the view?

Cheers

EDIT:

public class GetDataTask extends
    AsyncTask<Context, Void, FriendListAdapter> {

    @Override
    protected void onPostExecute(FriendListAdapter result) {
    friendList.onRefreshComplete();
        friendList.getRefreshableView().setAdapter(result);

        friendList.getRefreshableView().setOnItemClickListener(itself);
        friendList.getRefreshableView().getChildCount();
    }

This bit of code acts very strangely. The adapter is set but the getChildCount returns 0 even though the list showing on screen clearly shows ~15 things on the list. This

Paul Thompson
  • 3,290
  • 2
  • 31
  • 39

2 Answers2

2
public void onWindowFocusChanged(boolean hasFocus) {};
Omar Abdan
  • 1,901
  • 17
  • 29
  • This is what i usually do in the case that i am just starting the activity. Would this work for when you change the adapter on a list though? – Paul Thompson Jan 27 '13 at 06:57
  • Just tried this, it doesn't get called apart from just after onCreate. Cheers for trying – Paul Thompson Jan 27 '13 at 07:00
  • look at this link please [http://stackoverflow.com/questions/7088738/when-the-getview-method-of-listview-gets-called-in-android/7088758#7088758][1] – Omar Abdan Jan 27 '13 at 07:24
1

if the problem is just with getting the count of the items. You can tr this

friendlist.getRefreshableView.getCount()

please see here

Swati
  • 1,179
  • 9
  • 28