انجمن سایت کلیدستان


رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
تغیر فونت لیست ویو

تغیر فونت لیست ویو

#5
برای این کار باید از custom adapter یا به اصطلاع adapter شخضی سازی شده استفاده کنید

برای این کار باید ابتدا یک کلاس جدید بسازیر و اون رو از arrayadapter یا baseadapter مشتقم بگیرید یا extend کنید.
بعدش درون این کلاس جدید میتونید هز تغییراتی که میخواید رو برو روی ردیفهای list خودیتون اعمال کنید

در زیر یه نمونه از کلاس گفته شده قرار داده شده میتونید از ازش کمک بگیرید.

کد:
public class ListAdapter extends ArrayAdapter<Item> {

   public ListAdapter(Context context, int textViewResourceId) {
       super(context, textViewResourceId);
   }

   public ListAdapter(Context context, int resource, List<Item> items) {
       super(context, resource, items);
   }

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

       View v = convertView;

       if (v == null) {
           LayoutInflater vi;
           vi = LayoutInflater.from(getContext());
           v = vi.inflate(R.layout.itemlistrow, null);
       }

       Item p = getItem(position);

       if (p != null) {
           TextView tt1 = (TextView) v.findViewById(R.id.id);
           TextView tt2 = (TextView) v.findViewById(R.id.categoryId);
           TextView tt3 = (TextView) v.findViewById(R.id.description);

           if (tt1 != null) {
               tt1.setText(p.getId());
           }

           if (tt2 != null) {
               tt2.setText(p.getCategory().getId());
           }

           if (tt3 != null) {
               tt3.setText(p.getDescription());
           }
       }

       return v;
   }

}

این هم layout مربوط به ردیف های list شما ( کلاس بالا )
کد پی‌اچ‌پی:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content" android:orientation="vertical"
    android:layout_width="fill_parent">

    <TableRow android:layout_width="fill_parent"
              android:id="@+id/TableRow01"
              android:layout_height="wrap_content">

        <TextView android:textColor="#FFFFFF"
                  android:id="@+id/id"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:text="id" android:textStyle="bold" 
                  android:gravity="left"
                  android:layout_weight="1" 
                  android:typeface="monospace"
                  android:height="40sp" />
    </TableRow>

    <TableRow android:layout_height="wrap_content"
              android:layout_width="fill_parent">

        <TextView android:textColor="#FFFFFF" 
                  android:id="@+id/categoryId"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:text="categoryId" 
                  android:layout_weight="1" 
                  android:height="20sp" />

        <TextView android:layout_height="wrap_content"
                  android:layout_width="fill_parent" 
                  android:layout_weight="1"
                  android:textColor="#FFFFFF"
                  android:gravity="right"
                  android:id="@+id/description"
                  android:text="description" 
                  android:height="20sp" />
    </TableRow>

</TableLayout> 
پاسخ
 سپاس شده توسط hossein5513 ، شماره مجازی امارات ، تلگرام ضد فیلتر 2023


پیام‌های این موضوع
تغیر فونت لیست ویو - توسط hossein5513 - ۱۳۹۵/۰۲/۰۹, ۱۲:۳۷ ب.ظ
RE: تغیر فونت لیست ویو - توسط u3fraja - ۱۳۹۵/۰۲/۰۹, ۰۶:۱۸ ب.ظ
RE: تغیر فونت لیست ویو - توسط hossein5513 - ۱۳۹۵/۰۲/۰۹, ۰۸:۲۲ ب.ظ
RE: تغیر فونت لیست ویو - توسط hossein5513 - ۱۳۹۵/۰۲/۱۲, ۱۰:۴۹ ب.ظ
RE: تغیر فونت لیست ویو - توسط mahdi10539 - ۱۳۹۵/۰۲/۱۳, ۱۰:۴۸ ق.ظ

پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان