爲何RecyclerView沒有onItemClickListener()? [關閉]

問題:

Closed . 已關閉 This question is opinion-based. 這個問題是基於意見的。 It is not currently accepting answers. 它當前不接受答案。 Learn more . 瞭解更多

Want to improve this question? 想改善這個問題嗎? Update the question so it can be answered with facts and citations by editing this post . 更新問題,以便經過編輯此帖子以事實和引用的形式回答。 android

Closed 4 months ago . 4個月前關閉。 ide

I was exploring RecyclerView and I was surprised to see that RecyclerView does not have onItemClickListener() . 我在瀏覽RecyclerView ,驚訝地發現RecyclerView沒有onItemClickListener() Because RecyclerView extends 因爲RecyclerView擴展 post

android.view.ViewGroup android.view.ViewGroup 性能

and ListView extends ListView擴展 this

android.widget.AbsListView android.widget.AbsListView spa

. However I solved my problem by writing onClick in my RecyclerView.Adapter : 可是我經過在RecyclerView.Adapter編寫onClick解決了個人問題: .net

public static class ViewHolder extends RecyclerView.ViewHolder implements OnClickListener {

    public TextView txtViewTitle;
    public ImageView imgViewIcon;

    public ViewHolder(View itemLayoutView) {
        super(itemLayoutView);
        txtViewTitle = (TextView) itemLayoutView.findViewById(R.id.item_title);
        imgViewIcon = (ImageView) itemLayoutView.findViewById(R.id.item_icon);
    }

    @Override
    public void onClick(View v) {

    }
}

But still I want to know why Google removed onItemClickListener() ? 可是我仍然想知道爲何Google刪除了onItemClickListener() code

Is there a performance issue or something else? 是否存在性能問題或其餘問題? orm


解決方案:

參考一: https://stackoom.com/question/1gPmZ/爲何RecyclerView沒有onItemClickListener-關閉
參考二: https://oldbug.net/q/1gPmZ/Why-doesn-t-RecyclerView-have-onItemClickListener-closed
相關文章
相關標籤/搜索