开发者

ListView and undeterminate ProgressBar

Sorry for the question it might sounds stupid,

But: how d开发者_如何学运维o you activate a ProgressBar according to the cell you just cliked on ?

I have a list view, with a menu that shows after a long press.

When I click on one of my option I would like to display the ProgressBar in the listView according to the cell I clicked on. It is currently always displaying the one of my first cell, whatever I am doing

public boolean onContextItemSelected(MenuItem item) {
     AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

     switch (item.getOrder()) {
        case 0:
                    mProgressBar = (ProgressBar)findViewById(R.id.welcome_progressbar);
                    mProgressBar.setVisibility(View.VISIBLE);
            ... some execution ....

                    return true;
        case 1:
                     ...

Does anyone see anything wrong?


That's because findViewById finds first instance of the View in the list. You need to handle that through your item states in your getView in the adapter. You can try to use states like selected/pressed or just set a boolean to your item, check it in getView, and show/hide progress based on that.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜