問題是這樣的: 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>
我還有其他幾個是正是這樣一個適配器和他們的工作只是罰款。我浪費了整整一天的時間(這可能是一個愚蠢的問題),任何幫助將不勝感激。謝謝。
請編輯您的問題,幷包含包含列表視圖的XML佈局。 – Simon
添加了佈局。謝謝。 –
在構造函數中初始化你的數組列表 –