views:

27

answers:

1

full code
how do i access the parent activity's mail layout elements? In this case a button. I have it declared in main.xml. When a button in the listview is clicked, i want to change the text of the button in main.

A: 

So you have a ListView and a button in your layout, and you want to change the button's text, when one of the buttons in your ListView is clicked? There're many ways to achieve this.

  1. You could pass the reference of your button to your custom Adapter class. That way you can accesss that button from the inner event handler calss you defined for the buttons in your list rows - so you can change its text.

  2. You could fire a broadcast intent from the row-buttons' event handlers. You listen for these intents in your Activity, and change the Button's text accordingly. This may be an overkill tho.

  3. Use a static method for it in the Activity.

etc.

Scythe