I have a RecyclerView with CardView which display the data read from the database.And this have no problem with it.
Now the problem is,I want to add a Linear layout which content both ImageView and TextView inside in the same RecyclerView,and make it always the First Element in the RecyclerView.
This is what I want to acheive.The first element in the RecyclerView is always the Linear Layout,no matter what different in the CardView below it.
I try this tutorial from this link it seems like handle the different ViewType depends of the data from the database,which is not what I want.
What I want is
1) This Linear Layout is static
2) Always the First element in the RecyclerView.
I check if(index == 0) in
onCreateViewHolder`the index just not recognised by the android studio.
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if(index== 0) {
View feedInput = LayoutInflater.from(parent.getContext())
.inflate(R.layout.feed_input, parent, false);
return new MyViewHolder(feedInput);
}else {
View feedItemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.feed_item, parent, false);
return new MyViewHolder(feedItemView);
}
}