需要更改TextView的字体

时间:2017-04-17 17:43:26

标签: android custom-font

我有一个包含listview的活动,并使用layout_list.xml文件将项添加到列表视图中。我需要在Layout_list中更改textview的字体。以下是将值存储到数组列表中的代码

public void processFinish(String s) {



    tourlist = new JsonConverter<Cricket>().toArrayList(s, Cricket.class);
    Log.d("Collegsearch",s);

//  sortlist();

    BindDictionary<Cricket> dict = new BindDictionary<Cricket>();
    dict.addStringField(R.id.toirname, new StringExtractor<Cricket>() {

        @Override
        public String getStringValue(Cricket cricket, int position) {
            return ""+cricket.tournamentname.toUpperCase();
        }
    });
    dict.addStringField(R.id.Entryfees, new StringExtractor<Cricket>() {
        @Override
        public String getStringValue(Cricket cricket, int position) {
            return "EntryFees: "+cricket.Entryfees;
        }
    });
    dict.addStringField(R.id.Location, new StringExtractor<Cricket>() {
        @Override
        public String getStringValue(Cricket cricket, int position) {
            return ":  "+cricket.Location;
        }
    });

    dict.addDynamicImageField(R.id.ivimage, new StringExtractor<Cricket>() {
                @Override
                public String getStringValue(Cricket item, int position) {
                    return item.imageurl;
                }
            }, new DynamicImageLoader() {
                @Override
                public void loadImage(String url, ImageView view) {
                    Picasso.with(Cricketpge.this).load(url).resize(150, 150).transform(new RoundedCornersTransformation(20, 20)).into((view));

                }
            });
            FunDapter < Cricket > adapter = new FunDapter<>(Cricketpge.this, tourlist, R.layout.layout_list, dict);



    crcketlist.setAdapter(adapter);

    crcketlist.setOnItemClickListener(this);
}

我尝试通过此方法更改字体

View mview = getLayoutInflater().inflate(R.layout.layout_list, null);

tournamee= (TextView) mview.findViewById(R.id.toirname);


    Typeface typeface= Typeface.createFromAsset(getAssets(),"fonts/Corbel Bold.ttf");
    tournamee.setTypeface(typeface);

0 个答案:

没有答案