I use below code to get the button click event:
Button b = (Button)v.findViewById(R.id.reminder_item_btn);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
Log.d("", timeString);
}
});
On Aug 26, 10:41 am, Andrew <[EMAIL PROTECTED]> wrote:
> Thank you very much. It is helpful.
>
> And I have another question.
>
> I defined the List item in a xml like below:
>
> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
> android:layout_width="fill_parent"
> android:layout_height="fill_parent"
> android:padding="5px">
>
> <TextView
> android:id="@+id/reminder_item_text"
> android:layout_width="wrap_content"
> android:layout_height="wrap_content"
> android:layout_alignParentRight="true" />
>
> <Button
> android:id="@+id/reminder_item_btn"
> android:layout_width="wrap_content"
> android:layout_height="wrap_content"
> android:layout_alignParentRight="true" />
>
> </RelativeLayout>
>
> You know, the listview would hold more than one item. Every item has a
> button with the same id "reminder_item_btn". Then how can i get to
> know which button is pressed?
>
> On Aug 26, 10:03 am, Mark Murphy <[EMAIL PROTECTED]> wrote:
>
> > Andrew wrote:
> > > I have a question about the ListView.
>
> > > Example:
> > > In a ListView, there are many items. If I press up/down key to select
> > > one item, what I want is show a button on the selected view, and if
> > > the selected item is unselected, the button will be hide.
>
> > > How can I change the layout when the item gets selected?
>
> > You might not be able to wholesale change the layout, but you can make
> > widgets visible/invisible/gone via setVisibility().
>
> > A heavier approach would be to make each row in the list a ViewFlipper,
> > or include a ViewFlipper, so that you can swap out a button-showing and
> > a button-hiding view upon selection. I would think hiding a single
> > button would be less resource-intensive than using a ViewFlipper, but I
> > may be wrong.
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com
> > _The Busy Coder's Guide to Android Development_ Version 1.1 Published!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---