Why my buttons OnClick event fails to fire?
- by Pentium10
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?