رفتن به مطلب
انجمن اندروید ایران | آموزش برنامه نویسی اندروید و موبایل
  • android.png.1fab383bc8500cd93127cebc65b1dcab.png

تقییر فونت در لیست ویو


پست های پیشنهاد شده

سلام من برای لیست ویو از یک آداپتر استفاده کردم ولی هر کاری می کنم نمیتونم فونت رو تغییر بدم اینم کدی که توی آداپتر دارم.

[shcode=java]

public class CustomListAdapter extends ArrayAdapter{

    private final Activity context;

    private final String[] web;

    public CustomListAdapter(Activity context,

                      String[] web) {

        super(context, R.layout.custom_listview, web);

        this.context = context;

        this.web = web;

    }

    @Override

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

        LayoutInflater inflater = context.getLayoutInflater();

        View rowView= inflater.inflate(R.layout.custom_listview, null, true);

        TextView txtTitle = (TextView) rowView.findViewById(R.id.custom_txt);

        txtTitle.setText(web[position]);

        return rowView;

    }

}

[/shcode]

لینک ارسال
به اشتراک گذاری در سایت های دیگر

دستت درد نکنه دادا مشکلم این بود که وقتی میخواستم فونت رو فراخوانی کنم قسمت get asset ارور میداد و مشکل از اینجا بود که نوع آداپترم مشکل داشت و وقتی من اون رو  به

[shcode=java]ArrayAdapter[/shcode]

تغییر دادم درست شد. مثل کد زیر:

[shcode=java]public class CustomListAdapter extends ArrayAdapter{

    private final Activity context;

    Typeface tf;

    private final String[] web;

    public CustomListAdapter(Activity context,

                             String[] web) {

        super(context, R.layout.custom_list, web);

        this.context = context;

        this.web = web;

    }

    @Override

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

        LayoutInflater inflater = context.getLayoutInflater();

        View rowView= inflater.inflate(R.layout.custom_list, null, true);

        TextView txtTitle = (TextView) rowView.findViewById(R.id.custom_txt);

        txtTitle.setText(web[position]);

        tf = Typeface.createFromAsset(context.getAssets(),  "fonts/BKamran.ttf");

        txtTitle.setTypeface(tf);

        return rowView;

    }[/shcode]

لینک ارسال
به اشتراک گذاری در سایت های دیگر

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...