android中基类方法重写,[Android] [RecyclerView]方法不会覆盖或实现超类型的方法

我正在按照本教程开发一个简单的Android应用程序。我在此消息的onBindViewHolder方法上遇到编译错误:

错误:方法未覆盖或从超类型实现方法

这是我的代码:

import android.support.annotation.NonNull;

import android.support.v7.widget.RecyclerView;

import android.view.LayoutInflater;

import android.view.ViewGroup;

import android.widget.BaseAdapter;

import android.widget.TextView;

public class CryptogramPairingAdapter extends RecyclerView.Adapter {

private String[] mDataset;

// Provide a reference to the views for each data item

// Complex data items may need more than one view per item, and

// you provide access to all the views for a data item in a view holder

public static class ViewHolder extends RecyclerView.ViewHolder {

// each data item is just a string in this case

public TextView mTextView;

public ViewHolder(TextView v) {

super(v);

mTextView = v;

}

}

// Provide a suitable constructor (depends on the kind of dataset)

public CryptogramPairingAdapter(String[] myDataset) {

mDataset = myDataset;

}

// Create new views (invoked by the layout manager)

@Override

public ViewHolder onCreateViewHolder(ViewGroup parent,

int viewType) {

// create a new view

TextView v = (TextView) LayoutInflater.from(parent.getContext())

.inflate(R.layout.pair_crypto_recyclerview, parent, false);

CryptogramPairingAdapter.ViewHolder vh = new ViewHolder(v);

return vh;

}

// Replace the contents of a view (invoked by the layout manager)

@Override

public void onBindViewHolder(ViewHolder holder, int position) {

// - get element from your dataset at this position

// - replace the contents of the view with that element

holder.mTextView.setText(mDataset[position]);

}

// Return the size of your dataset (invoked by the layout manager)

@Override

public int getItemCount() {

return mDataset.length;

}

}

我很困惑,因为代码与引用几乎相同(除了修改后的名称)。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值