如何将Listview项目字体样式更改为MARATHI

时间:2013-09-27 07:37:10

标签: android

我想将List of List视图项更改为marathi,我使用Typeface更改TextField的字体,有人可以告诉我如何使用List View Items来实现它。

2 个答案:

答案 0 :(得分:2)

像这样创建一个自定义的textView类

public class CustomTextView extends TextView {

    public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    public CustomTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public CustomTextView(Context context) {
        super(context);
        init();
    }

    @SuppressWarnings("null")
    private void init() {
        if (!isInEditMode()) {


            // default style
            Typeface tf = Typeface.createFromAsset(getContext().getAssets(),
                    "helveticaneue_bold.ttf");


            setTypeface(tf);
        }
    }

在资源文件夹中放置您的字体样式(Marathi.ttf文件,在本例中我使用了helveticaneue_bold.ttf)。

现在在你的行中,你已经膨胀到ListView,而不是在

下面使用TextView
 <yourpackagename.CustomTextView
            android:id="@+id/tv_title"
            style="@style/buttontext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/company_profile" >
        </yourpackagename.CustomTextView>

答案 1 :(得分:0)

您必须实现CustomAdapter或BaseAdapter才能实现此目的。在getview方法中,将包含textview和settypeface的其他xml文件膨胀到它