I'm not able to put the custom font through Typeface, as getAssets() is not showing up while writing createFromAsset. I've used getContext(), getActivity(), placed the assets in the project and not in src, all not finding soln. Please tell me the error.
package com.example.shubhojit.careersafter10th.ViewHolder; import android.content.res.AssetManager; import android.graphics.Typeface; import android.support.v7.widget.RecyclerView; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import com.example.shubhojit.careersafter10th.Interface.ItemClickListener; import com.example.shubhojit.careersafter10th.R; public class Courses_After10thViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public TextView txtCourseName; public ImageView courseImage; public TextView txtCourseDuration; Typeface courseName; Typeface courseDuration; private ItemClickListener itemClickListener; public Courses_After10thViewHolder(View itemView) { super(itemView); txtCourseName = (TextView)itemView.findViewById(R.id.courses_after10th_name); courseImage = (ImageView)itemView.findViewById(R.id.courses_after10th_image); txtCourseDuration = (TextView)itemView.findViewById(R.id.courses_after10th_duration); courseName = Typeface.createFromAsset(context.getAssets(),"Fonts/Antipasto-RegularTrial.ttf"); itemView.setOnClickListener(this); } public void setItemClickListener(ItemClickListener itemClickListener) { this.itemClickListener = itemClickListener; } @Override public void onClick(View view) { itemClickListener.onClick(view,getAdapterPosition(),false); } }
contextin your code. Do you pass the context to your class correctly?