1

A GridView has BaseAdapter derived class responsible for populating its children. It works fine.

I want to do something when the GridView is refreshed. In other words, I wish there was a method "addOnRefreshListner()".

It needs to accommodate API Level as low as 8 (Froyo).

4

3 回答 3

0

如果您在自定义适配器中覆盖 BaseAdapter.notifyDataSetChanged() 会怎样?

@Override
public void notifyDataSetChanged() {
    super.notifyDataSetChanged();
    // A change has happened and caused the GridView to refresh
}
于 2012-08-28T19:21:54.243 回答
0

notifyDataSetChanged() 是没有 addOnRefreshListener() 的解决方案。

于 2012-08-28T19:28:11.130 回答
0

尝试View.OnLayoutChangeListener()为 API 11 或更高版本实现一个。

View myView = findViewById(R.id.my_view);
myView.addOnLayoutChangedListener(new OnLayoutChangeListener() {

@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {

      // Do what you need to do with the height/width since they are now set
    }
});
于 2012-08-28T19:29:24.953 回答