First the scenario:
I have a list where each item has a photo of a contact and some text. I would like to click on the image and bring up the QuickContactBadge
. Badge is defined by the following XML snippet
<QuickContactBadge android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="@+id/badge"
android:layout_alignParentBottom="true"></QuickContactBadge>
What I tried and failed:
RelativeLayout
RelativeLayout
What do I see:
Basically nothing. The code gets valid badge instance and then I apply the following logic
contactPhoto.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
Log.d(TAG, "Image click");
if (badge != null) {
badge.assignContactFromEmail("[email protected]", true);
badge.setMode(ContactsContract.QuickContact.MODE_SMALL);
badge.bringToFront();
}
}
});
As I click I can step through the code in onClick
handler yet the badge never comes up
The questions:
QuickContactBadge
have any placement logic? When I click on the image do I need to calculate badge position and readjust or is it built-in?Abort! Abort!
Basically I totally misunderstood what the badge is and how to use it. What I was trying to do is to detect click on image and call the badge. This is fundamentally wrong since all I needed to do was to simply use QuickContactBadge
INSTEAD of ImageView
in my code. After I replaced images with badges in the item XML magic was automatically there.
Said that - it is possible to pop the badge using the code, refer to this article on how to do it