我有一个listview
,其中包含一些cells
,而单元格中包含Buttons
。
这些按钮在初次尝试时可以正常工作,但在滚动后无法使用。状态更改为已选择,但未调用onClickListener
。
这是按钮的xml(它们实际上是IconButtons看到的: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" />
,然后在适配器中:
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());
}
}
}
});
我已经尝试过this,但对我来说不起作用。
我将一个简短的视频上传到了YouTube here。