i have this android volley code. i dont have any problem here.
private void sendRequest() {
StringRequest stringRequest = new StringRequest(JSON_url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d("HomeFragment", response);
showJSON(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_LONG).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(getActivity());
requestQueue.add(stringRequest);
}
private void showJSON(String json) {
MySingleton listJson = new MySingleton(json);
listJson.mySingleton();
List<myHome> homeData = new ArrayList<>();
homeData.add(new myHome(MySingleton.vid_title, MySingleton.vid_desc, MySingleton.vid_duration, MySingleton.vid_thumbnail, MySingleton.embed_url, MySingleton.ids) );
mAdapter = new HomeAdapter(getContext(), homeData);
mRecyclerView.setAdapter(mAdapter);
and here is my adapter.
private String[] vid_title;
private String[] vid_desc;
private String[] vid_duration;
private String[] vid_thumbnail;
private String[] vid_embedUrl;
private int[] type;
private LayoutInflater inflater = null;
private List<myHome> multipleRowModelList;
private Context context;
public HomeAdapter(Context context, String[] title, String[] desc, String[] duration, String[] thumbnail, String[] embedUrl, int[] type) {
this.context = context;
this.vid_title = title;
this.vid_desc = desc;
this.vid_duration = duration;
this.vid_thumbnail = thumbnail;
this.vid_embedUrl = embedUrl;
this.type = type;
inflater = LayoutInflater.from(context);
}
my problem is here.
@Override
public int getItemCount() {
return (multipleRowModelList != null && multipleRowModelList.size() > 0 ) ? multipleRowModelList.size() : 0;
}
@Override
public int getItemViewType(int position) {
myHome multipleRowModel = multipleRowModelList.get(position);
if (multipleRowModel != null)
return type[position];
return super.getItemViewType(position);
}
@Override
public void onBindViewHolder(final FeaturedViewHolder holder, final int position) {
holder.featured_title.setText(multipleRowModelList.get(position).getTitle());
holder.featured_user.setText(multipleRowModelList.get(position).getUser());
the error is says, cannot resolve method 'setText(java.lang.String[])'
my model has data that is like this. String[] and int[].
any way i can do this?
here is the handler
public FeaturedViewHolder(View itemView, int type) {
super(itemView);
if (type == AppConstant.TYPE_FEATURED) {
featured_title = (TextView)itemView.findViewById(R.id.title);
featured_user = (TextView)itemView.findViewById(R.id.recvid_auth);
mRelativeLayout = (RelativeLayout)itemView.findViewById(R.id.relative_recycler);
}
else if(type == AppConstant.TYPE_OTHER) {
featured_title = (TextView)itemView.findViewById(R.id.recvid_title);
featured_user = (TextView)itemView.findViewById(R.id.description);
mRelativeLayout = (RelativeLayout)itemView.findViewById(R.id.relative_recycler_other);
}
}
here is the model
public class myHome {
String[] vid_title;
String[] vid_desc;
String[] vid_duration;
String[] vid_thumbnail;
String[] vid_embedUrl;
int[] type;
public myHome(String[] title, String[] desc, String[] duration, String[] thumbnail, String[] embedUrl, int[] type) {
this.vid_title = title;
this.vid_desc = desc;
this.vid_duration = duration;
this.vid_thumbnail = thumbnail;
this.vid_embedUrl = embedUrl;
this.type = type;
}
public String[] getTitle() {
return vid_title;
}
public String[] getUser() {
return vid_desc;
}
public String[] getViews() {
return vid_duration;
}
public String[] getUrl() {
return vid_thumbnail;
}
public String[] getDuration() {
return vid_embedUrl;
}
public int[] getType() {
return type;
}
i have edited my question