I have a listview
which contains some cells
and the cells contains Buttons
.
The buttons work fine on first attempt but after scrolling, they do not work. The state changes to selected but the onClickListener
is not getting called.
Here's the xml for the button (they're IconButtons actually see: android-iconify)
<com.joanzapata.iconify.widget.IconButton
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_gravity="right"
android:gravity="right|center|top"
android:paddingRight="30dp"
android:layout_toRightOf="@id/icon_map_marker"
android:layout_alignParentRight="true"
android:textColor="@drawable/hj_button_text_color_blue"
android:text="{fa-user}"
android:background="@color/default_transparent_color"
android:ellipsize="end"
android:id="@+id/textView_ad_detail_authorName"
android:maxLines="1"
android:focusable="false"
android:textSize="13sp" />
and then in the adapter:
IconButton buttonUsername = (IconButton) adDetailView.findViewById(R.id.textView_ad_detail_authorName);
buttonUsername.setText("\u200F" + "{fa-user 16sp @color/hj_color_blue}" + " " + ad.getAuthorName() + " " + "{fa-thumbs-up 16sp @color/hj_color_green}");
buttonUsername.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
IconButton button = (IconButton) view;
String username = ad.getAuthorName();
if (delegate != null) {
try {
delegate.usernamePushed(username, button.getId());
}
catch (Exception e) {
Crashlytics.logException(e.getCause());
}
}
}
});
I already tried this but it did not work for me.
I uploaded a short video to youtube here.