第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為 RecyclerView 項(xiàng)目創(chuàng)建選項(xiàng)菜單

為 RecyclerView 項(xiàng)目創(chuàng)建選項(xiàng)菜單

UYOU 2021-09-03 15:50:37
我一直在嘗試按照以下教程將選項(xiàng)菜單集成到我的列表視圖中:[ https://www.simplifiedcoding.net/create-options-menu-recyclerview-item-tutorial/]我已經(jīng)能夠讓菜單圖標(biāo)出現(xiàn)在列表視圖中的項(xiàng)目旁邊,但我無(wú)法點(diǎn)擊它來(lái)訪問(wèn)彈出菜單。我試圖在我的public void onBindViewHolder(MyViewHolder holder, int position)方法中實(shí)現(xiàn)這一點(diǎn)。我無(wú)法弄清楚為什么我無(wú)法執(zhí)行 onClick。我已經(jīng)發(fā)布了我的適配器代碼public class LeagueAdapter extends RecyclerView.Adapter<LeagueAdapter.MyViewHolder> {    private Context context;    private List<League> leaguesList;    public TextView buttonViewOption;    public void notifyDatasetChanged(List<League> newleagueslist) {        leaguesList.clear();        leaguesList.addAll(newleagueslist);        super.notifyDataSetChanged();    }    public class MyViewHolder extends RecyclerView.ViewHolder {        public TextView name;        public TextView basescore;        public TextView basescorepercentage;        private TextView leagueAverage;        public TextView id;        public TextView timestamp;        public TextView buttonViewOption;        public MyViewHolder(View view) {            super(view);            id = view.findViewById( R.id.tvLeagueId);            name = view.findViewById(R.id.tvSeriesName );            basescore = view.findViewById(R.id.tvBaseScore );            basescorepercentage = view.findViewById(R.id.tvBaseScorePercentage );            leagueAverage = view.findViewById(R.id.tvLeagueAverage);            timestamp = view.findViewById(R.id.timestamp);            buttonViewOption = (TextView) itemView.findViewById(R.id.textViewOptions);        }    }    public LeagueAdapter(Context context, List<League> leaguesList) {        this.context = context;        this.leaguesList = leaguesList;    }    @Override    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {        View itemView = LayoutInflater.from(parent.getContext())                .inflate(R.layout.listview_league, parent, false);        return new MyViewHolder(itemView);    } 
查看完整描述

2 回答

?
白衣非少年

TA貢獻(xiàn)1155條經(jīng)驗(yàn) 獲得超0個(gè)贊

您在 上初始化了錯(cuò)誤的上下文public LeagueAdapter(Context context, List<League> leaguesList),從 更改 this.mCtx=mCtx 為
this.mCtx = context 將解決問(wèn)題。

查看完整回答
反對(duì) 回復(fù) 2021-09-03
  • 2 回答
  • 0 關(guān)注
  • 191 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)