开发者

android - listview onPrerender() or something like that

I have a custom control that extends ListView. I want to add a custom code for my custom listview to set selection and want to do it once in all my code. Is there a method on the listview that is executed after onResume() of activity that holds the control.

I want to centralize my code in one place, that is ListView method that executes after the method bel开发者_StackOverflow社区ow:

@Override
    public void onResume()
    {
       super.onResume();


       this._listItems.requestFocusFromTouch(); 
       this._listItems.setSelection(StateManager.getCurrentState().getLastListViewPosition());

    }

The point is so I don't have ot do it in EVERY of over 100 screens I have but make this change in my custom listview.

Thank you in advance!


protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);


     this._listItems.requestFocusFromTouch(); 
       this._listItems.setSelection(myPositionFromMemory);

    }

the only thing you would need to watch out for is the sorts and stuff. Because if you are doing that after the listview is loaded you will end up with your selection always at the top.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜