I would like to know how to use a different layout with the layout below, if I'm in Activity A show Layout 1, if I'm in Activity B show Layout 2, I saw it done with viewType, but I could not understand how the viewType works, if you can explain how it works I appreciate it. in my case just have to change even the layout the rest is all the same.
public class RecyclerViewTeste extends RecyclerView.Adapter<RecyclerViewTeste .MyViewHolder> {
private List<Blog> mQuestionList;
Context mContext;
class MyViewHolder extends RecyclerView.ViewHolder {
View mView;
TextView title,desc,nome,data,uid,cont,mRetes;
ImageView mExpand;
CircleImageView mCirclePerfil;
MyViewHolder(View view) {
super(view);
mView = view;
mContext = mView.getContext();
title = (TextView) view.findViewById(R.id.post_title);
desc = (TextView) view.findViewById(R.id.post_desc);
nome = (TextView) view.findViewById(R.id.post_username);
data = (TextView) view.findViewById(R.id.datarow);
uid = (TextView) view.findViewById(R.id.uid);
}
public void setFtperfil(Context ctx, String ftperfil) {
CircleImageView post_perfil = (CircleImageView) mView.findViewById(R.id.imagemPerfil);
Picasso.with(ctx).load(ftperfil).into(post_perfil);
}
}
public RecyclerViewClashOfClans(List<Blog> mQuestionList) {
this.mQuestionList = mQuestionList;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.blog_row_cliente, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(MyViewHolder holder, final int position) {
final Blog blog = mQuestionList.get(position);
holder.title.setText(blog.getTitle());
holder.desc.setText(blog.getDesc());
holder.nome.setText(blog.getNome());
holder.data.setText(blog.getData());
holder.uid.setText(blog.getId_post());
holder.setFtperfil(getApplicationContext(), blog.getFoto());
holder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent singleBlogIntent = new Intent(mContext, BlogSingleActivityClash.class);
singleBlogIntent.putExtra("blog_id", blog.getId_post());
mContext.startActivity(singleBlogIntent);
}
});
}
@Override
public int getItemCount() {
return mQuestionList.size();
}
}