I would like to show JSON Object's data into RecyclerView
for that I have tried this but did not get any data.
May, I know where I am doing mistake
and What I have missed
?
How could I pass learning
objects data from MainAdapter
to LearningActivity
MainAdapter class:
@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(rowLayout, viewGroup, false);
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(ViewHolder viewHolder, int i) {
final Value value = values.get(i);
........
List<Learning> learning = value.getLearning();
viewHolder.btnCallNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, LearningActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
}
});
}
LearningActivity class:
public class LearningActivity extends AppCompatActivity {
......
mAdapter = new LearningAdapter(valueList, R.layout.card_learning, getApplicationContext());
mRecyclerView.setAdapter(mAdapter);
}
}
about setting your data
This is new, empty ArrayList. You should fill it if you didn't already do it. To test you implementation, you could add 2 empty objects:
At least, the recyclerview now should contain 2 empty items.
//Edit: Gnarf, you posted a whole new adapter while editing your question. Please ignore my above quoted text and next time think about what code you post before you ask ...
your adapter class
In your Adapter class, you need to implement
getItemCount()
. Because this method is abstract I assume you've already done it: http://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html#getItemCount%28%29Finally, I have
resolved
my own issue.I found a very simple and straight solution here
Glad! worked for me