所以,我有一个表中的数据,所以我使用适配器。下面是我如何在适配器中设置它
public View getView(int position, View convertView, ViewGroup parent) {
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = inflater.inflate(R.layout.list_item, parent,false);
// get your views here and set values to them
TextView ItemCodetextview = (TextView) row.findViewById(R.id.itemcode);
TextView ItemNametextview = (TextView) row.findViewById(R.id.itemname);
GenerateItemdoModel current = dataModels.get(position);
ItemCodetextview.setText(current.getItemCode());
ItemNametextview.setText(current.getItemName());
return row;
}
list\u项目
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_marginTop="20sp"
android:layout_marginRight="20sp"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:id="@+id/itemcode"
android:textSize="12sp"
android:text="1"
android:textStyle="bold"
android:layout_marginLeft="20sp"
android:ellipsize="marquee"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:id="@+id/itemname"
android:layout_marginLeft="20sp"
android:text="2"
android:textSize="12sp"
android:ellipsize="marquee"
android:textStyle="bold"
android:layout_height="wrap_content" />
</LinearLayout>
xml中的微调器
<LinearLayout
android:layout_marginLeft="20sp"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:text="Item Code"
android:textStyle="bold"
android:layout_gravity="center"
android:gravity="center"
android:textSize="12sp"
android:layout_height="match_parent" />
<Spinner
android:id="@+id/itemcodeval"
android:layout_width="match_parent"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_marginLeft="40sp"
android:layout_marginStart="40sp"/>
<EditText
android:id="@+id/valueitemcde"
android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="wrap_content" />
</LinearLayout>
我的默认微调器(不带适配器)
<LinearLayout
android:layout_marginTop="30sp"
android:layout_marginLeft="20sp"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:text="Tipe Rijek"
android:layout_gravity="center"
android:textStyle="bold"
android:gravity="center"
android:textSize="12sp"
android:layout_height="match_parent" />
<Spinner
android:id="@+id/tipeval"
android:layout_width="match_parent"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_marginLeft="40sp"
android:layout_marginStart="40sp"
/>
<EditText
android:id="@+id/valuetipe"
android:layout_width="wrap_content"
android:visibility="gone"
android:textSize="12sp"
android:layout_height="wrap_content" /> </LinearLayout>
这是带有适配器的自定义微调器的屏幕截图
这是默认微调器
因此,我的问题是如何使自定义微调器看起来像默认微调器?提前谢谢,对不起我的英语