I'm confronted with a new issue, the situation I'm facing is as follows :

I have a ListView when I click an element, I use startActivityForResult to go a new ListView from which the user can grab a piece of information which sent back to the first ListView by finishing the Activity and sending back the result.

Now, I would like to be able to display this result in the row that was clicked, but I don't get how to navigate inside the views of the adapter. The only option I'm seeing right now is to tag each view in my adapter and grab it later, with this tag. Is there any better way?

(Each row in my ListView is composed with 2 TextView and an ImageView, I'd like to put the result in the 2nd TextView)

有帮助吗?

解决方案

I can suggest a way to avoid tagging..

you start a new activity after you get a click , so in onItemClick

private TextView secondText;

public void onItemClick(AdapterView<?> parent, View contentView, int position, long Id) {
            // get access to the textView you want to change by
                        secondText = (TextView) contentView.findViewById(R.id.textViewId);
        }

changing the text in the onActivityResult should be easy as you have access to the textView already.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top