I have a setup a viewpager with 3 fragments. The first page of my viewpager contains data from a database. How can i implement a progress bar for only the first page just before the data gets loaded.
Custom fragment =>
public class HomeContentFragment extends Fragment {
public static ArrayList<ShishaBar> arrayList;
public static ContentAdapter adapter;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
RecyclerView recyclerView = (RecyclerView) inflater.inflate(
R.layout.recycler_view, container, false);
adapter = new ContentAdapter();
recyclerView.setAdapter(adapter);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
new BackgroundWorker().execute();
return recyclerView;
}
public static class ViewHolder extends RecyclerView.ViewHolder {
public ImageView picture;
public TextView name;
public TextView description;
public ViewHolder(LayoutInflater inflater, ViewGroup parent) {
super(inflater.inflate(R.layout.item_card, parent, false));
picture = (ImageView) itemView.findViewById(R.id.card_image);
name = (TextView) itemView.findViewById(R.id.card_title);
description = (TextView) itemView.findViewById(R.id.card_text);
itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Context ctx = v.getContext();
Intent intent = new Intent(ctx, DetailActivity.class);
intent.putExtra(DetailActivity.EXTRA_POSITION, getAdapterPosition());
ctx.startActivity(intent);
}
});
}
}
public static class ContentAdapter extends RecyclerView.Adapter<ViewHolder> {
public ContentAdapter() {
arrayList = new ArrayList<>();
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext()), parent);
}
#Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.picture.setImageBitmap(arrayList.get(position).getImage());
holder.name.setText(arrayList.get(position).getName());
holder.description.setText(arrayList.get(position).getStraat()+ " " + arrayList.get(position).getHuisnr()+ ", "+arrayList.get(position).getStad());
}
#Override
public int getItemCount() {
return arrayList.size();
}
}
}
If i put a progressbar on the viewpager, all the pages get the progress bar, I only want it on the first page. And if I put the progressbar in the xml of my card_view you can't see the progress bar until data is loaded.
in the adapter of the ViewPager, check the index of the page like:
public void instantiateItem(...,int position){
if(position == 0){
/* inflate a view that contains the ProgressBar and process it */
...
}
}
Related
I am building an Android Application which have Tab Layout in which there are Fragments and in Fragment I am displaying some value.
I have just only added hardcoded values to test the layout, but even these are not visible in the fragment.
Here is the code for ViewPagerAdapter:
public class FavouriteViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> favouriteFragmentList = new ArrayList<>(); // this line can cause crashes
private final List<String> favouriteFragmentListTitles = new ArrayList<>();
public FavouriteViewPagerAdapter(#NonNull FragmentManager fm, int behavior) {
super(fm, behavior);
}
#NonNull
#Override
public Fragment getItem(int position) {
return favouriteFragmentList.get(position);
}
#Override
public int getCount() {
return favouriteFragmentListTitles.size();
}
#Nullable
#Override
public CharSequence getPageTitle(int position) {
return favouriteFragmentListTitles.get(position);
}
public void AddFragment(Fragment fragment, String title) {
favouriteFragmentList.add(fragment); // this line can cause crashes
favouriteFragmentListTitles.add(title);
}
}
I have tried the answers available already none of them solves my problem.
I debugged the application and my RecyclerViewAdapter is not even called, very strange. I have done this many time but this never happened.
Here is my code for RecyclerViewAdapter :
public class ProductsRecyclerAdapter extends RecyclerView.Adapter<ProductsRecyclerAdapter.viewHolder> {
Context context;
private List<FavouriteProducts> favouriteProductsData;
public ProductsRecyclerAdapter(Context context, List<FavouriteProducts> favouriteProductsData) {
this.context = context;
this.favouriteProductsData = favouriteProductsData;
}
#NonNull
#Override
public viewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(context).inflate(R.layout.single_favourite_product_item, parent, false);
viewHolder vHolder = new viewHolder(v);
return vHolder;
}
#Override
public void onBindViewHolder(#NonNull viewHolder holder, int position) {
holder.product_name.setText(favouriteProductsData.get(position).getProduct_name());
holder.product_price.setText(favouriteProductsData.get(position).getProduct_price());
holder.product_image.setImageResource(favouriteProductsData.get(position).getProduct_image());
Toast.makeText(context,favouriteProductsData.get(position).getProduct_price() , Toast.LENGTH_SHORT).show();
/*holder.heart_button.setOnLikeListener(new OnLikeListener() {
#Override
public void liked(LikeButton likeButton) {
showSuccessToast(context,"Liked");
}
#Override
public void unLiked(LikeButton likeButton) {
showSuccessToast(context,"Unliked");
}
});*/
}
#Override
public int getItemCount() {
return favouriteProductsData.size();
}
static class viewHolder extends RecyclerView.ViewHolder {
MaterialTextView product_name, product_price;
ImageView product_image;
LikeButton heart_button;
public viewHolder(#NonNull View itemView) {
super(itemView);
product_name = itemView.findViewById(R.id.product_name);
product_price = itemView.findViewById(R.id.product_price);
product_image = itemView.findViewById(R.id.product_image);
heart_button = itemView.findViewById(R.id.heart_button);
}
}
}
I am not getting any errors but after I check adapter is not even called. Some help will be really helpful.
Fragment Code:
public class FavouriteProductsFragment extends Fragment {
View v;
private List<FavouriteProducts> productList;
public FavouriteProductsFragment() {
}
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
productList = new ArrayList<>();
productList.add(new FavouriteProducts("All Weather", "200/Ltr", R.drawable.all_weather));
}
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
v = inflater.inflate(R.layout.products_favourite_fragment, container, false);
RecyclerView productRecyclerView = v.findViewById(R.id.favourite_products_rv);
ProductsRecyclerAdapter recyclerAdapter = new ProductsRecyclerAdapter(getContext(), productList);
productRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
productRecyclerView.hasFixedSize();
productRecyclerView.setAdapter(recyclerAdapter);
return v;
}
}
productList = new ArrayList<>();
productList.add(new FavouriteProducts("All Weather", "200/Ltr",R.drawable.all_weather));
recyclerAdapter.notifyDataSetChanged()
RecyclerView productRecyclerView = v.findViewById(R.id.favourite_products_rv);
ProductsRecyclerAdapter recyclerAdapter = new ProductsRecyclerAdapter(getContext(), productList);
productRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
productRecyclerView.hasFixedSize();
productRecyclerView.setAdapter(recyclerAdapter);
You need to add
RecyclerView productRecyclerView = v.findViewById(R.id.favourite_products_rv);
ProductsRecyclerAdapter recyclerAdapter = new ProductsRecyclerAdapter(getContext(), productList);
productRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
productRecyclerView.hasFixedSize();
productRecyclerView.setAdapter(recyclerAdapter);
productList = new ArrayList<>();
productList.add(new FavouriteProducts("All Weather", "200/Ltr",R.drawable.all_weather));recyclerAdapter.notifyDataSetChanged()
and Remove oncreate() method
try productRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); befor setting adapter in recyclerview.
Step1: First Create one or MoreFragment For Your ViewPager and in This Fragment Add your Recyclerview Code as per Your Requirement.
Like Below Code
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_whatsapp_image, container, false);
context = getActivity();
((HomeActivity) getActivity()).toolbar.setVisibility(View.VISIBLE);
setupView(root);
return root;
}
private void setupView(ViewGroup root) {
recyclerView = (RecyclerView) root.findViewById(R.id.recyclerViewImage);
progressBar=root.findViewById(R.id.simpleProgressBar);
txtinfo=root.findViewById(R.id.txtinfo);
setUPList();
}
Step2: Then Create ViewPager Adapter for Your TabLayout
public class ViewPagerAdapter extends FragmentPagerAdapter {
public ViewPagerAdapter(FragmentManager fragmentManager) {
super(fragmentManager);
}
#Override
public Fragment getItem(int position) {
if(position == 0) return new AudioFragment();
if(position == 1) return new VideoFragment();
if(position == 2) return new ImageFragment();
throw new IllegalStateException("Unexpected position " + position);
}
#Override
public int getCount() {
return 3;
}
#Override
public CharSequence getPageTitle(int position) {
if(position == 0) return "Audio";
if(position == 1) return "Video";
if(position == 2) return "Image";
throw new IllegalStateException("Unexpected position " + position);
}
}
Step3 : Then Call Your SetupViewpager Method in Your Oncreate method of your Activity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar=findViewById(R.id.toolbar);
viewPager=findViewById(R.id.viewpager);
tabLayout=findViewById(R.id.tabs);
//add toolbar
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setupViewPager(viewPager);
tabLayout.setupWithViewPager(viewPager);
setTabIcons();
}
NOTE: You Can Download ViewPager Code from Below Link.Click Here to View and Download
can i use ListFragment to achieve what I said above or i need a custom recycler view inside a fragment, I tried to put a recycler view inside fragment but i didn't know how to make the onClick for recycler view work with fragment so it passes data to another fragment or another activity in case of multi-pane UI, so can i use list fragment or my only choice is recycler view, if it's then how can I do it in recycler view ?
my MainActivity which has a fragment that contains the recycler view
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FragmentManager fm = getSupportFragmentManager();
Fragment fragment = fm.findFragmentById(R.id.main_fragment_container);
if (fragment == null) {
fragment = new FragmentRecyclerList();
fm.beginTransaction()
.add(R.id.main_fragment_container, fragment)
.commit();
}
}
}
my fragment which contains the recycler view
public class FragmentRecyclerList extends Fragment implements MyDialog.OnInputSelected {
private RecyclerView recyclerView;
private RecyclerViewAdapter recyclerViewAdapter;
private List<String> titles;
private FloatingActionButton fab;
public FragmentRecyclerList() {
// Required empty public constructor
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_fragment_recycler_list, container, false);
}
void showDialog() {
MyDialog myDialog = new MyDialog();
myDialog.setTargetFragment(FragmentRecyclerList.this, 1);
myDialog.show(getFragmentManager(), "MyDialog");
}
#Override
public void onActivityCreated(#Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
recyclerView = getView().findViewById(R.id.recyclerview);
fab = getView().findViewById(R.id.floatingActionButton);
titles = new ArrayList<>();
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerViewAdapter = new RecyclerViewAdapter(getActivity(), titles);
recyclerView.setAdapter(recyclerViewAdapter);
fab.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
showDialog();
}
});
}
}
my recycler view adapter
public class RecyclerViewAdapter extends
RecyclerView.Adapter {
private Context context;
private List<String> titles;
public RecyclerViewAdapter(Context context, List<String> titles) {
this.context = context;
this.titles = titles;
}
#NonNull
#Override
public ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_wallpaper
, parent, false);
return new ViewHolder(view);
}
#Override
public void onBindViewHolder(#NonNull ViewHolder holder, int position) {
String title = titles.get(position);
holder.tvTitle.setText(title);
}
#Override
public int getItemCount() {
return titles.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public TextView tvTitle;
public ViewHolder(#NonNull View itemView) {
super(itemView);
View v = itemView;
tvTitle = itemView.findViewById(R.id.row_title);
}
}
}
I'm am trying to open a new fragment by selecting the image from the card view within the recycler view. Preferable using both adapter and fragment classes. How do I do that?
This is my adapter class:
public class CorporateAdapter extends RecyclerView.Adapter {
private int[] images = {
R.drawable.sample1,
R.drawable.sample2
};
#Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.corporate_list_row, viewGroup, false);
final MyViewHolder vHold = new MyViewHolder(view);
return vHold;
}
#Override
public void onBindViewHolder(#NonNull RecyclerView.ViewHolder viewHolder, int i) {
((MyViewHolder) viewHolder).bindView(i);
}
#Override
public int getItemCount() {
return images.length;
}
private class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
private ImageView mImageView;
public MyViewHolder(View itemView) {
super(itemView);
mImageView = (ImageView) itemView.findViewById(R.id.showImage);
mImageView.setOnClickListener(this);
}
public void bindView(int position) {
mImageView.setImageResource(images[position]);
}
#Override
public void onClick(View v) {
}
}
This is my Fragment class:
public class CorporateFragment extends Fragment {
private final int LAYOUT_LISTCORPORATE_FRAGMENT = R.layout.corporate_membership;
private View v;
private Date date;
private RecyclerView recyclerView;
private RecyclerView.LayoutManager layoutManager;
public CorporateFragment() {
}
public static CorporateFragment newInstance(Date date) {
CorporateFragment fragment = new CorporateFragment();
Bundle args = new Bundle();
//args.putSerializable(ARG_DATE,date);
fragment.setArguments(args);
return fragment;
}
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
// Inflate the layout for this fragment
v = inflater.inflate(LAYOUT_LISTCORPORATE_FRAGMENT, container, false);
ButterKnife.bind(this, v);
return v;
}
#Override
public void onViewCreated(#NonNull View view, #Nullable Bundle savedInstanceState) {
recyclerView = (RecyclerView) v.findViewById(R.id.recyclerView);
final CorporateAdapter listAdapter = new CorporateAdapter();
recyclerView.setAdapter(listAdapter);
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
}
I've seen some ways where by we can open up the new fragment straight from the adapter, but the more correct way would be having the Onclicklistener in both the fragment class and adapter class.
Is there any way I could do that? Thank you
Here is An example for You paste as it is.
Make constructor which will have an interface as parameter in adapter and override it in Fragment.
Your Fragment Code will look like this.
public class CorporateFragment extends Fragment {
private final int LAYOUT_LISTCORPORATE_FRAGMENT = R.layout.corporate_membership;
private View v;
private Date date;
private RecyclerView recyclerView;
private RecyclerView.LayoutManager layoutManager;
public CorporateFragment() {
}
private int[] images = {
R.drawable.sample1,
R.drawable.sample2
};
public static CorporateFragment newInstance(Date date) {
CorporateFragment fragment = new CorporateFragment();
Bundle args = new Bundle();
//args.putSerializable(ARG_DATE,date);
fragment.setArguments(args);
return fragment;
}
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState) {
// Inflate the layout for this fragment
v = inflater.inflate(LAYOUT_LISTCORPORATE_FRAGMENT, container, false);
ButterKnife.bind(this, v);
return v;
}
#Override
public void onViewCreated(#NonNull View view, #Nullable Bundle savedInstanceState) {
recyclerView = (RecyclerView) v.findViewById(R.id.recyclerView);
final CorporateAdapter listAdapter = new CorporateAdapter(getActivity(), images, new CorporateAdapter.onItemClickListener() {
#Override
public void onItemClick(View view, int position) {
/////////////////// do your on Click Stuff here...
/////////// for ex .. go to next fragment
}
});
recyclerView.setAdapter(listAdapter);
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
}
}
And Your adapter is set to go like this
public class CorporateAdapter extends RecyclerView.Adapter<CorporateAdapter.MyViewHolder> {
Context context;
private int[] images;
onItemClickListener onItemClickListener;
public CorporateAdapter(Context context, int[] images, CorporateAdapter.onItemClickListener onItemClickListener) {
this.context = context;
this.images = images;
this.onItemClickListener = onItemClickListener;
}
#Override
public MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.corporate_list_row, viewGroup, false);
final MyViewHolder vHold = new MyViewHolder(view);
return vHold;
}
#Override
public void onBindViewHolder(#NonNull MyViewHolder holder, final int position) {
((MyViewHolder) holder).bindView(position);
holder.mImageView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
onItemClickListener.onItemClick(view,position);
}
});
}
#Override
public int getItemCount() {
return images.length;
}
private class MyViewHolder extends RecyclerView.ViewHolder {
private ImageView mImageView;
public MyViewHolder(View itemView) {
super(itemView);
mImageView = (ImageView) itemView.findViewById(R.id.showImage);
}
public void bindView(int position) {
mImageView.setImageResource(images[position]);
}
}
public interface onItemClickListener{
void onItemClick(View view , int position);
}
}
Hope it will help. Good Luck
I have 2 fragments, A and B. fragment B contains the recyclerview and it is populated when fragment B is loaded. However, when i press back in fragment B and I go back to fragment A I try to go back to fragment B again but the recyclerview is not populated.
The strange thing is that it does get populated after i change the screen orientation.
How do I populate the recyclerview after going back to fragment B?
Setting adapter in onCreateView of fragment B:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
recyclerView = (RecyclerView) view.findViewById(R.id.rvPlaylists);
recyclerView.setHasFixedSize(true);
layoutManager = new GridLayoutManager(getActivity(),1);
recyclerView.setLayoutManager(layoutManager);
PlaylistAdapter adapter = new PlaylistAdapter(savedPlaylists);
recyclerView.setAdapter(adapter);
}
Adapter:
public class PlaylistAdapter extends
RecyclerView.Adapter<PlaylistAdapter.ViewHolder>
{
private Context mContext;
private ArrayList<Playlist> mPlaylists;
private LayoutInflater mInflater;
public PlaylistAdapter(ArrayList<Playlist> playlists)
{
mPlaylists = playlists;
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.playlist_recyclerview_item, parent, false);
return new ViewHolder(v);
}
#Override
public void onBindViewHolder(ViewHolder holder, int position)
{
Playlist currentPlaylist = mPlaylists.get(position);
holder.tvName.setText(currentPlaylist.getName());
holder.btnPlayPlaylist.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View v) {
Log.d("btn clicked","mlk");
}
});
}
#Override
public int getItemCount()
{
return mPlaylists.size();
}
public class ViewHolder extends RecyclerView.ViewHolder
{
public TextView tvName;
public ImageButton btnPlayPlaylist;
public ViewHolder(View v)
{
super(v);
tvName = (TextView) v.findViewById(R.id.lblPlaylistName);
btnPlayPlaylist = (ImageButton) v.findViewById(R.id.btnPlayPlaylist);
}
}
Loading Fragment B:
public void navigateFromPlaylistFragmentToSavedPlaylistFragment()
{
getFragmentManager().beginTransaction().replace(R.id.activity_main, new SavedPlaylistFragment()).addToBackStack("navigatefromplaylistfragmenttosavedplaylistfragment")
.commit();
}
You didn't call adapter.notifyDataSetChanged(); after initializing Adapter and populating data.
I am using FragmentStatePagerAdapter to load fragment with viewpager with tab layout. I am passing different id's to load same fragment with different data in getItem() but it is always returning fragment with same data on first time and when I swipe through next screens and came back to first screen then it will showing correct data.
Any solution or info is very helpful.
I am calling adapter like this in my onCreate() and it always return same data for position 0 and 1.
MyPagerAdapter adapter = new MyPagerAdapter (getSupportFragmentManager(),bundle);
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
My Adapter
static class MyPagerAdapter extends FragmentStatePagerAdapter {
private Bundle b;
public MyPagerAdapter (FragmentManager fm,Bundle b) {
super(fm);
this.b=b;
}
#Override
public Fragment getItem(int position) {
ContentListFragment fragment = new ContentListFragment();
b.putString("id", tabList.get(position).get("id"));
fragment.setArguments(b);
return fragment;
}
#Override
public int getCount() {
return tabList.size();
}
#Override
public CharSequence getPageTitle(int position) {
return tabList.get(position).get("title");
}
}
Edit
ContentListFragment.java
public class ContentListFragment extends Fragment{
private static final String TAG="ContentListFragment";
private String id,type;
private TextView norecord;
private View rootView;
private List<AppReading> appReadingList;
private RecyclerView recyclerView;
private ContentRecyclerAdapter adapter;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
Log.d(TAG, "onCreateView");
rootView = inflater.inflate(R.layout.content_list, container,false);
initView();
initData();
return rootView;
}
private void initView() {
// TODO Auto-generated method stub
norecord=(TextView)rootView.findViewById(R.id.norecord);
recyclerView=(RecyclerView) rootView.findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
}
private void initData() {
id=getArguments().getString("id");
getContentList(category);
}
// Get records by category
private void getContentList(String id){
Log.d(TAG, "getContentList: "+id);
Dao dao=new Dao(getActivity());
dao.open();
appReadingList=dao.getContentList(id);
dao.close();
//Set adapter if data available
if(appReadingList.size()>0){
adapter=new ContentRecyclerAdapter();
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),R.drawable.divider));
recyclerView.setItemAnimator(new FadeInLeftAnimator());
recyclerView.setAdapter(new SlideInLeftAnimationAdapter(adapter));
}else{
norecord.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.GONE);
}
}
private class ContentRecyclerAdapter extends RecyclerView.Adapter<ContentRecyclerAdapter.ViewHolder>{
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.listitem, parent, false);
ViewHolder holder = new ViewHolder(v);
return holder;
}
#Override
public void onBindViewHolder(ViewHolder holder,final int position) {
holder.itemContent.setText(appReadingList.get(position).getTitle());
holder.itemDate.setText(appReadingList.get(position).getAddDate());
}
#Override
public int getItemCount() {
return appReadingList.size();
}
#Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
super.onAttachedToRecyclerView(recyclerView);
}
class ViewHolder extends RecyclerView.ViewHolder{
TextView itemContent, itemDate ;
RelativeLayout listItem;
ViewHolder(View itemView){
super(itemView);
itemContent = (TextView) itemView.findViewById(R.id.itemcontent);
itemDate = (TextView) itemView.findViewById(R.id.itemdate);
listItem=(RelativeLayout) itemView.findViewById(R.id.rlListItem);
}
}
}