1 回答
TA贡献2003条经验 获得超2个赞
好的,所以要实现这一点,您首先需要创建 xml 视图,例如:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
现在在函数中的适配器中,getView()您需要对其进行充气并绑定TextView:
convertView = LayoutInflater.from(context).
inflate(R.layout.layout_list_view_row_items, parent, false);
TextView nameTextView = (TextView) convertView.findViewById(R.id.name_text_view);
//and now get the SpinnerArrayObject by position
SpinnerArrayObject currentObject = spinnerArrayObjects.get(position);
nameTextView.setText(currentObject.getName());
return convertView;
添加回答
举报