I am trying to pull data from Parse.com cloud to my android application.This is the code for my custom adapter:
public class AdvertisingAdapter extends RecyclerView.Adapter<AdvertisingAdapter.TatsViewHolder> {
List<AdvertInfo> data = new ArrayList<>();
private LayoutInflater inflater;
public AdvertisingAdapter(Context context, List<AdvertInfo> data){
inflater = LayoutInflater.from(context);
this.data = data;
}
#Override
public TatsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflater.inflate(R.layout.single_ad, parent, false);
TatsViewHolder holder = new TatsViewHolder(view);
return holder;
}
#Override
public void onBindViewHolder(TatsViewHolder holder, int position) {
AdvertInfo current = data.get(position);
holder.daPoster.setText(current.theadvertiser);
holder.daAdvert.setText(current.theadvert);
}
#Override
public int getItemCount() {
return data.size();
}
class TatsViewHolder extends RecyclerView.ViewHolder{
TextView daPoster;
TextView daAdvert;
public TatsViewHolder(View itemView) {
super(itemView);
daPoster = (TextView)itemView.findViewById(R.id.txtAdvertiser);
daAdvert = (TextView)itemView.findViewById(R.id.txtAdvert);
}
}
}
and the code for my member class
public class AdvertInfo {
public String theadvertiser;
public String theadvert;
}
then for my fragment where i am displaying the data here is the code
public class ViewAdverts extends android.support.v4.app.Fragment {
private RecyclerView myRecyclerView;
AdvertisingAdapter myAdapter;
public ViewAdverts() {
// Required empty public constructor
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View layout = inflater.inflate(R.layout.view_adverts, container, false);
myRecyclerView = (RecyclerView)layout.findViewById(R.id.advert_list);
myAdapter = new AdvertisingAdapter(getActivity(), getData());
myRecyclerView.setAdapter(myAdapter);
myRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
return layout;
}
public static List<AdvertInfo> getData(){
final List<AdvertInfo> myposts = new ArrayList<>();
ParseQuery<Posts> query = ParseQuery.getQuery(Posts.class);
query.findInBackground(new FindCallback<Posts>() {
#Override
public void done(List<Posts> list, ParseException e) {
if (e == null){
for (int i = 0; i < list.size(); i++){
AdvertInfo ad = new AdvertInfo();
ad.theadvertiser = list.get(i).getString(ParseConstants.ADVERTISER);
ad.theadvert = list.get(i).getString(ParseConstants.DESCRIPTION);
myposts.add(ad);
}
}
}
});
return myposts;
}
}
I have tried to debug by putting breaks on getData method in the fragment I am get the data but I dont know why my recycler view appearing empty when I run.
Related
My Recycler view in image and name which is contained in ArrayList it not show particular like ArrayList in containing all image and name and the last image and name show "ArrayList.size" times like I enter four images and four names so last input image and last input name are shown in recycler view four times.
fragment.java class:
public class Revfragment extends Fragment {
public Revfragment() {
// Required empty public constructor
}
ArrayList<gettersetter> arrayList = new ArrayList<>();
CustomeAepter customeAepter;
RecyclerView recyclerView;
String name[] = {"kishan","karan","jigar","raman"};
int img[] = {R.drawable.a,R.drawable.ad,R.drawable.ac,R.drawable.ab};
RecyclerView.LayoutManager manager;
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initDataset();
}
private void initDataset() {
for (int i = 0; i < name.length; i++) {
gettersetter gettersetter = new gettersetter(img[i], name[i]);
arrayList.add(gettersetter);
}
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootview= inflater.inflate(R.layout.fragment_revfragment, container, false);
recyclerView = rootview.findViewById(R.id.revs);
manager = new LinearLayoutManager(getActivity());
customeAepter = new CustomeAepter(getActivity(),arrayList);
recyclerView.setAdapter(customeAepter);
recyclerView.setLayoutManager(manager);
return rootview;
}
}
Adapter class
public class CustomeAepter extends RecyclerView.Adapter<CustomeAepter.myclass> {
TextView textView;
ImageView imageView;
ArrayList<gettersetter> arrayList;
Context context;
public CustomeAepter(Context cotexts,ArrayList<gettersetter> arrayLists) {
arrayList = arrayLists;
context = cotexts;
}
#NonNull
#Override
public CustomeAepter.myclass onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.textitem,parent,false);
return new myclass(v);
}
#Override
public void onBindViewHolder(#NonNull CustomeAepter.myclass holder, int position) {
holder.getTextView().setText(gettersetter.getName());
holder.getImageView().setImageResource(gettersetter.getImg());
}
#Override
public int getItemCount() {
return arrayList.size();
}
public class myclass extends RecyclerView.ViewHolder {
public myclass(#NonNull View itemView) {
super(itemView);
textView = itemView.findViewById(R.id.txt);
imageView = itemView.findViewById(R.id.img);
}
public TextView getTextView() {
return textView;
}
public ImageView getImageView()
{
return imageView;
}
}
}
You are not using the arraylist in your Adapter. You have to set the value according to the item at corresponding adapter position. Change you onBindViewHolder as follows:
#Override
public void onBindViewHolder(#NonNull CustomeAepter.myclass holder, int position) {
holder.getTextView().setText(arrayList.get(position).getName());
holder.getImageView().setImageResource(arrayList.get(position).getImg());
}
By this your data will be set according to the items at positions in the list you have passed to the adapter.
This is my fragment code below.
public class pendingactivity extends Fragment {
MyViewModel myViewModel;
List<Activity_> activity_list;
CheckBox act_check;
View view;
int project_id;
Projectid_pointing_towards_activity PPta;
public pendingactivity() {
// Required empty public constructor
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
RecyclerView mrecyclerView;
//Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_pendingactivity, container, false);
mrecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view_frag1);
act_check = (CheckBox) view.findViewById(R.id.activity_check);
myViewModel = ViewModelProviders.of(getActivity()).get(MyViewModel.class);
myViewModel.GetAllPPTA().observe(this, new Observer<List<Projectid_pointing_towards_activity>>()
{
#Override
public void onChanged(List<Projectid_pointing_towards_activity> PPTA) {
PPta = PPTA.get(1);
project_id = PPta.getProject_id();
}
});
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
mrecyclerView.setLayoutManager(linearLayoutManager);
final activitycardAdaptor Acticityadaptor = new activitycardAdaptor(getContext(), project_id);
myViewModel.GetAllActivity().observe(this, new Observer<List<Dactivity>>() {
#Override
public void onChanged(List<Dactivity> dactivities) {
Acticityadaptor.setActivity(dactivities);
}
});
mrecyclerView.setAdapter(Acticityadaptor);
return view;
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
below is my recyler adapter code
package com.example.builderpro;
public class activitycardAdaptor extends RecyclerView.Adapter<ActivityCardViewHolder> {
private Context context;
private List<Dactivity> mactivity;
int project_id;
public activitycardAdaptor(Context context, int id) {
this.context = context;
this.project_id = id;
}
#Override
public ActivityCardViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View mview = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_activity, parent,
false);
return new ActivityCardViewHolder(mview);
}
#Override
public void onBindViewHolder(ActivityCardViewHolder holder, int position) {
Dactivity dactivity = mactivity.get(position);
holder.Activity_title.setText(dactivity.getName());
holder.Activity_Type.setText(dactivity.getType());
Calendar calendar = Calendar.getInstance();
String curentDate = DateFormat.getDateInstance(DateFormat.FULL).format(calendar.getTime());
holder.Date.setText(curentDate);
}
#Override
public int getItemCount() {
return mactivity == null ? 0 : mactivity.size();
}
public void setActivity(List<Dactivity> dactivities) {
Dactivity current_activity;
for (int i = 0; i < dactivities.size(); i++) {
current_activity = dactivities.get(i);
if (project_id == current_activity.getProject_id()) {
mactivity.add(current_activity);
}
}
notifyDataSetChanged();
}
}
class ActivityCardViewHolder extends RecyclerView.ViewHolder {
CardView mcardview;
TextView Activity_title, Activity_Type, Date;
CheckBox activity_check;
public ActivityCardViewHolder(View itemView) {
super(itemView);
Activity_title = itemView.findViewById(R.id.Activity_name);
Activity_Type = itemView.findViewById(R.id.activity_type);
Date = itemView.findViewById(R.id.date);
activity_check = itemView.findViewById(R.id.activity_check);
mcardview = itemView.findViewById(R.id.activity_card);
}
}
Same code i'm running in another fragment and adapter and there is no error at debug time . i have tried many solution available on internet but nothing going right for my code. i think data is not entering in the list name of mactivity in adapter. Kindly help me because i'm stuck on this about 3 days.
I don't know if it's a mistake in your post or if it's in your code but something looks rather strange here final activitycardAdaptor Acticityadaptor = new activitycardAdaptor(getContext(), project_id); shouldn't it be final ActivitycardAdaptor acticityAdaptor = new ActivitycardAdaptor(getContext(), project_id); ?
i am trying to add a recyclerview on a fragment
fragments code:
public class MediaPlayerController extends Fragment{
private static final String TAG = "MediaPlayerController";
private RecyclerView recyclerViewb;
private RecycleViewAdapter myAdapter;
private ArrayList<String> myRecordings = new ArrayList<>();
//private DBHelper dbHelper;
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
Log.d(TAG, "onCreateView: started");
View v = inflater.inflate(R.layout.media_player_area, container, false);
recyclerViewb = (RecyclerView)v.findViewById(R.id.recyclerViewXml);
//dbHelper = new DBHelper(v.getContext(), null, null, 1);
myRecordings.add("hau");
myRecordings.add("hau2");
myRecordings.add("hau3");
myRecordings.add("hau4");
myRecordings.add("ha5");
myRecordings.add("hau23");
myRecordings.add("ha31u");
myRecordings.add("haudsa");
System.out.println("what does this print?"+myRecordings);
myAdapter = new RecycleViewAdapter(v.getContext(), myRecordings);
recyclerViewb.setAdapter(myAdapter);
recyclerViewb.setLayoutManager(new LinearLayoutManager(v.getContext()));
Log.d(TAG, "onCreateView: returned");
return v;
}
in the logs i see that that it doesn't even get to the RecycleViewAdapter sections of code at all the fragment is completely blank
i get not errors as well
public class RecycleViewAdapter extends RecyclerView.Adapter<RecycleViewAdapter.ViewHolder>{
private static final String TAG = "RecycleViewAdapter";
private Context mContext;
private ArrayList<String> mRecName = new ArrayList<>();
public RecycleViewAdapter(Context mContext, ArrayList<String> mRecName) {
this.mContext = mContext;
this.mRecName = mRecName;
}
#NonNull
#Override
public ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
Log.d(TAG, "onCreateViewHolder: i am here");
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.single_row_recycle, parent, false);
ViewHolder holder = new ViewHolder(view);
return holder;
}
#Override
public void onBindViewHolder(#NonNull final ViewHolder holder, int position) {
Log.d(TAG, "onBindViewHolder: called");
holder.recTxt.setText(mRecName.get(position).toString());
holder.parentLayout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(mContext, "sas gamaw", Toast.LENGTH_LONG);
}
});
}
#Override
public int getItemCount() {
return 0;
}
public class ViewHolder extends RecyclerView.ViewHolder{
RelativeLayout parentLayout;
TextView recTxt;
public ViewHolder(View itemView) {
super(itemView);
recTxt = itemView.findViewById(R.id.recTextView);
parentLayout = itemView.findViewById(R.id.parentLayoutXml);
}
}
}
in the logs it only displays oncreateView started and the myRecordings arraylist
onCreateView: started
I/System.out: what does this print?[hau, hau2, hau3, hau4, ha5,
hau23, ha31u, haudsa]
MediaPlayerController: onCreateView: returned
i can't think of what is going wrong :/ please help out
i also want to add that i am fairly new to android studio thanks
your code problem it is in Recycler Adapter in getItemCount() method,
You don't return any Item , you must change it to :
#Override
public int getItemCount() {
return mRecName.size();
}
I am unable to get data in my recycler view.I am very new to android and trying to implement this recycler view in tablayout but not getting any data .There are three tab and trying this code with one tab.Please help me out with this.Thanks in advance.
My code is below.
I have created two xml file one for recyler view and another one for custom rows.
Below here is my activity code.
My Fragment Activity
public class HomeFragment extends Fragment {
private RecyclerView recyclerView;
private vivzadapter adapter;
public HomeFragment() {
// Required empty public constructor
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View layout = inflater.inflate(R.layout.fragment_home, container, false);
recyclerView= (RecyclerView)layout.findViewById(R.id.lis);
adapter = new vivzadapter(getActivity(), getData());
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
return layout;
}
public static List<Information> getData(){
List<Information> data =new ArrayList<>();
int icons=(R.drawable.icon);
String[] titles = {"Ashish", "shivam", "yogesh", "ravi"};
for (int i=0;i<titles.length;i++) {
Information information = new Information();
information.iconId=icons;
information.title=titles[i];
data.add(information);
}
return data;
}
}
My Adapter Activity-
public class vivzadapter extends RecyclerView.Adapter<vivzadapter.MyViewHolder>{
private final LayoutInflater inflater;
List<Information> data= Collections.emptyList();
public vivzadapter(Context context,List<Information> data){
inflater =LayoutInflater.from(context);
this.data = data;
}
#Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= inflater.inflate(R.layout.customrow, parent,false);
MyViewHolder holder= new MyViewHolder(view);
return holder ;
}
#Override
public void onBindViewHolder(MyViewHolder holder, int position) {
Information current = data.get(position);
holder.title.setText(current.title);
holder.icon.setImageResource(current.iconId);
}
#Override
public int getItemCount() {
return 0;
}
class MyViewHolder extends RecyclerView.ViewHolder{
TextView title;
ImageView icon;
public MyViewHolder(View itemView) {
super(itemView);
title =(TextView) itemView.findViewById(R.id.textvw);
icon =(ImageView) itemView.findViewById(R.id.imageView);
}
}
}
Change
#Override
public int getItemCount() {
return 0;
}
to:
#Override
public int getItemCount() {
return data.size();
}
homepageThis is my fragment class
public class Premiums extends Fragment {
private RecyclerView recyclerPremium;
private RecyclerView.LayoutManager mLayoutManager;
private List<FeaturedAddDetails> featuredAddDetailsList = new ArrayList<>();
private List<PremiumDetails> premiumDetailslist = new ArrayList<>();
private NewestAdapter newestAdapter;
private PremiumAdapter premiumAdapter;
private String jsonResponse;
private PremiumDetails premiumDetails;
private JSONObject jsonobject;
public Premiums() {
}
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View mainView = inflater.inflate(R.layout.premium_fragment, container, false);
recyclerPremium = (RecyclerView) mainView.findViewById(R.id.recycler_premium);
premiumAdd();
premiumAdapter = new PremiumAdapter(getActivity().getApplicationContext(), premiumDetailslist);
recyclerPremium.setAdapter(premiumAdapter);
return mainView;
}
#Override
public void onViewCreated(View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
recyclerPremium.setLayoutManager(mLayoutManager);
recyclerPremium.setHasFixedSize(true);
}
private void premiumAdd() {
PremiumRequestHandler premiumHandler = new PremiumRequestHandler("premiumADD");
premiumHandler.executeAsStringRequest(new Response.Listener<String>() {
#Override
public void onResponse(String response) {
Log.e("response", response);
JSONArray jsonarray = null;
try {
jsonarray = new JSONArray(response);
} catch (JSONException e) {
e.printStackTrace();
}
for (int i = 0; i < jsonarray.length(); i++) {
try {
jsonobject = jsonarray.getJSONObject(i);
Log.e("id", String.valueOf(jsonobject.getInt("id")));
premiumDetails = new PremiumDetails(jsonobject.getInt("id"),
jsonobject.getInt("userid"),
jsonobject.getInt("mobile"),
jsonobject.getInt("cityid"),
jsonobject.getInt("price"),
jsonobject.getInt("comments"),
jsonobject.getInt("created"),
jsonobject.getInt("categoryid"),
jsonobject.getInt("MainCategoryID"),
jsonobject.getInt("views"),
jsonobject.getInt("ImageCount"),
jsonobject.getInt("storeid"),
jsonobject.getString("title"),
jsonobject.getString("default_photo"),
jsonobject.getString("CityName"),
jsonobject.getString("CategoryName"),
jsonobject.getString("currency"),
jsonobject.getString("description"));
premiumDetailslist.add(premiumDetails);
premiumAdapter.setPremiumDetails(premiumDetailslist);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}, new BaseRequest.ErrorResponseCallback() {
#Override
public void onError(Exception exception) {
}
});
}
This is my adapter class
public class PremiumAdapter extends RecyclerView.Adapter<PremiumAdapter.MyViewHolderPremium> {
private List<PremiumDetails> premiumDetailsList;
private ImageLoader imageLoader;
private Context context;
public PremiumAdapter(Context context, List<PremiumDetails> premiumDetailsList) {
this.premiumDetailsList = premiumDetailsList;
this.context = context;
notifyDataSetChanged();
}
public void setPremiumDetails(List<PremiumDetails> premiumDetailsList) {
this.premiumDetailsList = premiumDetailsList;
notifyDataSetChanged();
}
public class MyViewHolderPremium extends RecyclerView.ViewHolder {
private TextView txtTitle,txtDescription,txtCityName,txtPrice,txtCategory,txtHour,txtPhotoNo;
private NetworkImageView imgPhoto;
public MyViewHolderPremium(View itemView) {
super(itemView);
txtTitle = (TextView)itemView.findViewById(R.id.txt_title_fad);
txtDescription = (TextView)itemView.findViewById(R.id.description_fad);
txtCityName = (TextView)itemView.findViewById(R.id.city_name_fad);
txtPrice = (TextView)itemView.findViewById(R.id.price_fad);
txtCategory = (TextView)itemView.findViewById(R.id.category_fad);
txtHour = (TextView)itemView.findViewById(R.id.hours_fad);
txtPhotoNo = (TextView)itemView.findViewById(R.id.txt_photo_no_fad);
imgPhoto=(NetworkImageView)itemView.findViewById(R.id.img_photo_lod_fad);
}
}
#Override
public MyViewHolderPremium onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.featured_ad_adapter_layout,parent,false);
final MyViewHolderPremium myViewHolderPremium = new MyViewHolderPremium(itemView);
return myViewHolderPremium;
}
#Override
public void onBindViewHolder(MyViewHolderPremium holder, int position) {
PremiumDetails premiumDetails = premiumDetailsList.get(position);
holder.txtTitle.setText(premiumDetails.getTitle());
holder.txtDescription.setText(premiumDetails.getDescription());
holder.txtCityName.setText(premiumDetails.getCityName());
holder.txtPrice.setText(Integer.toString(premiumDetails.getPrice()));
holder.txtCategory.setText(premiumDetails.getCategoryName());
holder.txtHour.setText(Integer.toString(premiumDetails.getCreated()));
holder.txtPhotoNo.setText(Integer.toString(premiumDetails.getImageCount())+" photos " );
try {
imageLoader= VolleyHandler.getImageLoader();
} catch (Exception e) {
e.printStackTrace();
}
//imageLoader = CustomVolleyRequest.getInstance(context).getImageLoader();
//imageLoader.get(featuredAddDetails.getDefault_photo(), ImageLoader.getImageListener(holder.imgPhoto, R.mipmap.ic_launcher, android.R.drawable.ic_dialog_alert));
holder.imgPhoto.setImageUrl(premiumDetails.getDefault_photo(),imageLoader);
}
#Override
public int getItemCount() {
Log.e("size", String.valueOf(premiumDetailsList.size()));
return premiumDetailsList.size();
}}
I am getting error on showing values but I got values from json and I can't add it to adapter and model class, plz help me I look stackoverflow whole day but I can't find my issue
my getItemCount() is showing as 0"
You are setting the adapter and then you are calling premiumAdd() method.First call that method and then set the adapter.
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View mainView = inflater.inflate(R.layout.premium_fragment, container, false);
recyclerPremium = (RecyclerView) mainView.findViewById(R.id.recycler_premium);
premiumAdd();
premiumAdapter = new PremiumAdapter(getActivity().getApplicationContext(), premiumDetailslist);
recyclerPremium.setAdapter(premiumAdapter);
return mainView;
Try notifyDataSetChanged() after setting data in the Constructor of your Adapter
[EDIT] Whenever your data changes, you need to inform your Adapter about it also, then call notifyDataSetChanged() on it.
You are probably setting empty data into the Adapter, your List changes, but the Adapter does not know about it.
[Update]
In addition to your Adapter constructor, add a setData(List) to your adapter to change your dataset at runtime.
public void setPremiumDetails(List<PremiumDetails> premiumDetailsList) {
this.premiumDetailsList = premiumDetailsList;
notifyDataSetChanged();
}
When your request in premiumAdd() returns, and you receive a new set of data, you call setPremiumDetails on your Adapter with the new data and the List will update.
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
View mainView = inflater.inflate(R.layout.premium_fragment, container, false);
recyclerPremium = (RecyclerView) mainView.findViewById(R.id.recycler_premium);
mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
recyclerPremium.setLayoutManager(mLayoutManager);
recyclerPremium.setHasFixedSize(true);
premiumAdd();
premiumAdapter = new PremiumAdapter(getActivity().getApplicationContext(), premiumDetailslist);
recyclerPremium.setAdapter(premiumAdapter);
return mainView;
}
and remove premiumAdapter.notifyDataSetChanged();
added adapter code:
public class RVAdapter extends RecyclerView.Adapter<RVAdapter.ViewHolder> {
ArrayList<Model> dataset;
public RVAdapter(ArrayList<Model> dataset) {
this.dataset = dataset;
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.rv_item,parent,false);
return new ViewHolder(v);
}
#Override
public void onBindViewHolder(ViewHolder holder, int position) {
Model model = dataset.get(position);
holder.name.setText(model.name) ;
holder.status.setText(model.status);
if (model.status.equalsIgnoreCase("good"))
holder.ivStatus.setImageResource(R.drawable.ic_tick_48);
else
holder.ivStatus.setImageResource(R.drawable.ic_delete_48);
}
#Override
public int getItemCount() {
Log.e("TAG","SIZE: "+dataset.size());
return dataset.size();
}
public static class ViewHolder extends RecyclerView.ViewHolder {
TextView name;
TextView status;
ImageView ivStatus;
RelativeLayout parent;
public ViewHolder(View itemView) {
super(itemView);
name = (TextView) itemView.findViewById(R.id.rv_item_name);
status = (TextView) itemView.findViewById(R.id.rv_item_status);
ivStatus = (ImageView) itemView.findViewById(R.id.rv_item_iv);
parent = (RelativeLayout) itemView.findViewById(R.id.rv_item_parent);
}
}
}
your notifiy adapter on every single add
for (...){
....
premiumDetailslist.add(premiumDetails);
premiumAdapter.notifyDataSetChanged();// called every time wrong
}
also provide what exact error log says
and move the notifyDataSetChanged() after the for not in the loop
if no data is showing try recyclerview.invalidate , but i wont particularly do that way, would try debugging, log every step, inspect with method in the expected sequence isnt working