简体   繁体   English

如何将列表视图项目的字体设置为Marathi

[英]How to set Font of List View Items to Marathi

I'm using list view in my app, I want to the font of list view item in marathi, but certain error occurs and app get close. 我在我的应用程序中使用列表视图,我想在马拉地语中使用列表视图项的字体,但发生某些错误并且应用程序关闭。 Here is my code: 这是我的代码:

public View getView(int position, View convertView, ViewGroup parent) {

    View vi=convertView;
    ViewHolder holder;

    if(convertView==null){ 

        /********** Inflate tabitem.xml file for each row ( Defined below ) ************/
        vi = inflater.inflate(R.layout.tabitem, null); 

        /******** View Holder Object to contain tabitem.xml file elements ************/

        holder=new ViewHolder();
        holder.text.setTypeface(Typeface.createFromAsset(vi.getContext().getAssets(), "akshar.ttf"));
        holder.text1.setTypeface(Typeface.createFromAsset(vi.getContext().getAssets(), "akshar.ttf"));
        holder.text=(TextView)vi.findViewById(R.id.text);
        holder.text1=(TextView)vi.findViewById(R.id.text1);
        holder.image=(ImageView)vi.findViewById(R.id.image);

       /************  Set holder with LayoutInflater ************/
        vi.setTag(holder);
    }

The code you have pasted above is the Adapter class code, then just change 您上面粘贴的代码是Adapter类代码,然后进行更改

holder.text.setTypeface(Typeface.createFromAsset(vi.getContext().getAssets(), "akshar.ttf"));
    holder.text1.setTypeface(Typeface.createFromAsset(vi.getContext().getAssets(), "akshar.ttf"));

lines to .. 线到..

holder.text.setTypeface(Typeface.createFromAsset(context.getAssets(), "akshar.ttf"));
        holder.text1.setTypeface(Typeface.createFromAsset(context.getAssets(), "akshar.ttf"));

where 哪里

"context" is the Activity class context which you passing in this adapter class. “上下文”是您在此适配器类中传递的Activity类上下文。 if still your issue is unsolved then paste ur full code i'll definitely help you..Happy coding. 如果仍然无法解决您的问题,请粘贴您的完整代码,我肯定会为您提供帮助。

使用“ fonts / akshar.ttf”而不是“ akshar.ttf”。

First download the font file by going to Click here to download. 首先通过单击单击此处下载字体文件

Then in your project assets folder paste Roupya.ttf file. 然后在您的项目资产文件夹中粘贴Roupya.ttf文件。 in your main activity write Typeface typeface = Typeface.createFromAsset(getAssets(), "Roupya.ttf"); 在您的主要活动中,写出Typeface typeface = Typeface.createFromAsset(getAssets(), "Roupya.ttf");

and then yourTextView.setTypeface(typeface); 然后是yourTextView.setTypeface(typeface); this will work fine... I've checked then posting this answer. 这将正常工作...我已经检查过,然后发布此答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM