问题是这样的:arraylist 中有 49 项,适配器在第 3 项停止,没有任何错误通知。该应用程序不会崩溃,也不会显示任何文本视图。这是适配器:
public class ExhibitorObjectAdapter extends ArrayAdapter<ExhibitorObject> {
public ArrayList<ExhibitorObject> exhibitors;
public Activity act;
public TextView tvExhibitorName;
public ImageView ivExhibitorLogo;
public ExhibitorObjectAdapter(Activity a, int layoutResourceId, ArrayList<ExhibitorObject> ex) {
super(a, layoutResourceId,ex);
this.exhibitors = ex;
this.act = a;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return exhibitors.size();
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.single_exhibitor, null);
}
ExhibitorObject ex = exhibitors.get(position);
if (ex != null) {
//System.out.println(ex.companyName);
tvExhibitorName = (TextView) v.findViewById(R.id.textViewListExhibitorName);
tvExhibitorName.setText( ex.companyName );
}
return v;
}
}
编辑:这是包含列表视图的 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="horizontal" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:background="#134882"
android:paddingBottom="15sp"
android:paddingTop="5sp"
android:paddingLeft="5sp"
android:textColor="#FFFFFF"
android:text="Exhibitors" />
<ListView android:id="@+id/listViewExhibitors"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
</LinearLayout>
我还有其他几个与这个完全相同的适配器,它们工作得很好。我已经浪费了一整天的时间(这可能是一个愚蠢的问题),任何帮助将不胜感激。谢谢。