Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecyclerExampleAdapter gives errors #46

Closed
sschueller opened this issue Nov 18, 2016 · 2 comments
Closed

RecyclerExampleAdapter gives errors #46

sschueller opened this issue Nov 18, 2016 · 2 comments

Comments

@sschueller
Copy link

I am trying to implement the second example (Recipe 2 RecyclerView with Advanced ads) but I run into the following Issues:

RecyclerExampleAdapter.java

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;
import android.widget.ListView;
import com.clockbyte.admobadapter.ViewWrapper;
import java.util.ArrayList;
import java.util.List;

public class RecyclerExampleAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private List<String> items = new ArrayList<String>();
    private Context mContext;

    public RecyclerExampleAdapter(Context context){
        mContext = context;
    }

    @Override
    public viewGroup onBindViewHolder(ViewWrapper<RecyclerViewExampleItem> viewHolder, int position) {
        RecyclerViewExampleItem rvei = viewHolder.getView();
        String str = getItem(position);
        rvei.bind(str);
    }

    @Override
    public int getItemCount() {
        return items.size();
    }

    @Override
    protected RecyclerViewExampleItem onCreateItemView(ViewGroup parent, int viewType) {
        RecyclerViewExampleItem rvei = new RecyclerViewExampleItem(mContext);
        return rvei;
    }

    @Override
    public String getItem(int position) {
        return items.get(position);
    }

    public void addAll(List<String> lst){
        items.addAll(lst);
    }
}

RecyclerViewExampleItem.java

import android.content.Context;
import android.widget.FrameLayout;
import android.widget.TextView;

public class RecyclerViewExampleItem extends FrameLayout {

    TextView tvText;

    public RecyclerViewExampleItem(Context context) {
        super(context);
        //inflate(context, R.layout.recyclerview_item, this);
        //tvText = ((TextView) findViewById(R.id.tvText));
    }

    public void bind(String str){
        tvText.setText(str); //publishing the text from you data collection to each item in the RecyclerView
    }
}

Gives:

  • Class 'RecyclerExampleAdapter' must either be declared abstract or implement abstract method 'onBindViewHolder(VH, int)' in 'Adapter
  • Method does not override method from its superclass for public viewGroup onBindViewHolder
  • Method does not override method from its superclass for protected RecyclerViewExampleItem onCreateItemView
  • Method does not override method from its superclass for public String getItem

If I let Android Studio generate the methods I get:

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return null;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

    }

What am I missing?

@sschueller
Copy link
Author

Figured it out. Wiki is out of date, sample app works.

@kot331107
Copy link
Contributor

@sschueller Sorry for late answer. Yeah seems like that. I've updated Wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants