这是我的适配器文件,我在eclipse上收到错误。请帮帮我们:)这里是代码,你可以检查出来谢谢你们。这是我的适配器文件,我得到错误的日食。请帮帮我们:)这是代码,你可以检查出来谢谢你们。
private Activity activity;
private List<Pojo> itemsfavorite;
private Pojo objFavoriteBean;
private int row;
public Favorite_Activity_Adapter(Activity act, int resource, List<Pojo> arrayList) {
super(act, resource, arrayList);
this.activity = act;
this.row = resource;
this.itemsfavorite = arrayList;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view = convertView;
ViewHolder holder;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(row, null);
holder = new ViewHolder();
view.setTag(holder);
} else {
holder = (ViewHolder) view.getTag();
}
if ((itemsfavorite == null) || ((position + 1) > itemsfavorite.size()))
return view;
objFavoriteBean = itemsfavorite.get(position);
holder.txt_favoquote=(TextView)view.findViewById(R.id.text_dis);
holder.txt_favotitle=(TextView)view.findViewById(R.id.text_title);
//you can make any language quotes app just put ttf file in asset->font and below set ttf file
String fontPathtitle = "font/Kremlin.ttf";
Typeface tftitle = Typeface.createFromAsset(activity.getAssets(), fontPathtitle);
holder.txt_categorylistquote).setTypeface(tftitle);
holder.txt_title).setTypeface(tftitle);
String formattedString=android.text.Html.fromHtml(objFavoriteBean.getPQuote().toString()).toString();
holder.txt_favoquote.setText(formattedString);
return view;
}
public class ViewHolder {
public Object txt_title;
public Object txt_categorylistquote;
public TextView txt_favoquote,txt_favotitle;
}
}
谢谢你们答案 0 :(得分:0)
String fontPathtitle = "font/Kremlin.ttf";
Typeface tftitle = Typeface.createFromAsset(activity.getAssets(), fontPathtitle);
holder.txt_categorylistquote).setTypeface(tftitle);
holder.txt_title).setTypeface(tftitle);
你确定没问题吗?我看到一个类型错误(额外&#34;)&#34; in:
holder.txt_categorylistquote).setTypeface(tftitle);
holder.txt_title).setTypeface(tftitle);
应该是:
holder.txt_categorylistquote.setTypeface(tftitle);
holder.txt_title.setTypeface(tftitle);
更重要的是txt_title
和txt_categorylistquote
应该是ViewHolder中的TextView,因为setTypeface()
方法适用于Textviews