Why my buttons OnClick event fails to fire?

Posted by Pentium10 on Stack Overflow See other posts from Stack Overflow or by Pentium10
Published on 2010-05-18T17:27:34Z Indexed on 2010/05/18 17:30 UTC
Read the original article Hit count: 251

Filed under:
|
|
|

I have an activity, where the ListView holds customized linear layout elements for each row. One of the rows has a button defined as:

 <Button
            android:text="Pick a contact"
            android:id="@+id/btnPickContact"
            android:layout_width="wrap_content"
            android:gravity="center_vertical"
            android:layout_height="wrap_content"></Button>

Then in java, I have this code:

((Button) row.findViewById(R.id.btnPickContact)).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
                    intent.putExtra(EXTRA_ONLINE_ID, (String)v.getTag(TAG_ONLINE_ID));
                    act.startActivityForResult(intent, PICK_CONTACT);
                }
            });

In this setup the event fails to start.

Also I've tried by implementing the interface:

@Override
    public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
            intent.putExtra(EXTRA_ONLINE_ID, (String)v.getTag(TAG_ONLINE_ID));
            startActivityForResult(intent, PICK_CONTACT);
    }

still no luck, the event doesn't fire.

What to do?

© Stack Overflow or respective owner

Related posts about android

Related posts about android-sdk