previously I was using firebase recycler adapter and I used to get my child value using
final String NameKey = getRef(position).getKey();
and send that value using putExtraIntent and get that value in another activity.
now I am using custom recycler adapter and I am unable to use this code to get key value and use it in putExtraIntent. How can i do this ?
previously using firebase adapter ` FirebaseRecyclerAdapter adapter = new FirebaseRecyclerAdapter(options){
@Override
public NameHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.author_list_cv, parent, false);
return new NameHolder(view);
}
@Override
protected void onBindViewHolder(NameHolder holder, int position, AuthorsCLA model) {
final String AuthorNameKey = getRef(position).getKey();
holder.name.setText(model.getAuthorname());
holder.name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent quotesListIntent = new Intent(AuthorsList.this, AuthorQuotesDetailActvity.class);
quotesListIntent.putExtra("nameID", AuthorNameKey);
startActivity(quotesListIntent);
}
}); `
now I am trying this
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
final AuthorsCLA authorsModel = authorlist.get(holder.getAdapterPosition());
final String AuthorNameKey = getRef(position).getKey();
switch (holder.getItemViewType()) {
case A: {
NamesHolder nameHolder = (NamesHolder) holder;
nameHolder.name.setText(authorsModel.getAuthorname());
nameHolder.name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(view.getContext(), AuthorQuotesDetailActvity.class);
intent.putExtra("nameID",AuthorNameKey );
mcontext.startActivity(intent);
Toast.makeText(view.getContext(), authorsModel.getAuthorname(), Toast.LENGTH_SHORT).show();
}
});
but getRef is showing an error and when I hover on it, it says cannot resolve method getRef(int).
Use this