views:

172

answers:

1

Sorry for the question it might sounds stupid,

But: how do 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?

+1  A: 

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.

Alex Volovoy
After some research and re implementing an overload of the CursorAdapter class, I have acces to get getView() method. Problem is how can I call it when I want ? According to what I can see, getView() is called when I instantiate my CustomAdapter class. Hot to acces it at a certain point of my program? Do you have any idea ?
Spredzy