По каким-либо причинам getView (int position, View convertView, родительская группа ViewGroup) моего настраиваемого ArrayAdapter не вызывается, а андроид отображает пустой список. Я уже Override GetCount()getView из настроенного массива ArrayAdapter не называется
public class CEL_ElementsFromXMLArrayAdapter extends ArrayAdapter<LinkedHashMap<RoomItem, LinkedHashMap<ItemType, List<RoomDamage>>>> {
private Context context;
private int resource;
private List<LinkedHashMap<RoomItem, LinkedHashMap<ItemType, List<RoomDamage>>>> elementsFromXMLList;
public CEL_ElementsFromXMLArrayAdapter(Context context, int resource,
List<LinkedHashMap<RoomItem, LinkedHashMap<ItemType, List<RoomDamage>>>> elementsFromXMLList) {
super(context, resource, elementsFromXMLList);
this.context = context;
this.resource = resource;
this.elementsFromXMLList = elementsFromXMLList;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final int positionItem = position;
View view;
LayoutInflater viewInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if(convertView != null)
view = convertView;
else
view = viewInflater.inflate(R.layout.etat_piece_item, parent, false);
{...}
return view;
}
@Override
public int getCount() {
return this.elementsFromXMLList.size();
}
И это, как я установить адаптер:
CEL_ElementsFromXMLArrayAdapter cel_ElementsFromXMLArrayAdapter = new CEL_ElementsFromXMLArrayAdapter(mContext, R.layout.etat_piece_item, elementsFromXMLLinkedHashMap);
listViewElements.setAdapter(cel_ElementsFromXMLArrayAdapter);
Я ищу решение, так как вчера, я прочитал все посты на StackOverflow, но никто не соответствует моей проблеме. Так что я хотел бы знать, если это может исходить от LinkedHashMap < ...>
Edit: это мой макет R.layout.etat_piece_item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mis2_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dip"
android:background="@color/white"
android:orientation="horizontal"
android:weightSum="12" >
<ImageView
android:layout_width="@dimen/stroke_dim"
android:layout_height="fill_parent"
android:background="@color/light_line"
android:contentDescription="@string/img" />
<TextView
android:id="@+id/descriptionElement_TextView"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:clickable="true"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:textColor="@color/black1"
android:textSize="@dimen/mis_item_size" />
<ImageView
android:id="@+id/stroke_dim"
android:layout_width="@dimen/stroke_dim"
android:layout_height="fill_parent"
android:background="@color/light_line"
android:contentDescription="@string/img" />
<Spinner
android:id="@+id/typeElement_Spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_weight="2.5"
android:background="@drawable/spinner_ab_default"
android:clickable="true"
android:paddingLeft="5dp"
android:paddingTop="10dp"
android:textSize="@dimen/mis_item_size"
android:textStyle="normal" />
<ImageView
android:layout_width="@dimen/stroke_dim"
android:layout_height="fill_parent"
android:background="@color/light_line"
android:contentDescription="@string/img" />
<EditText
android:id="@+id/quantiteElement_EdiText"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:inputType="number"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:singleLine="true"
android:textColor="@color/black1"
android:textSize="@dimen/mis_item_size" />
<ImageView
android:layout_width="@dimen/stroke_dim"
android:layout_height="fill_parent"
android:background="@color/light_line"
android:contentDescription="@string/img" />
<TextView
android:id="@+id/etatElement_TextView"
style="@android:style/Widget.Holo.Light.EditText"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_weight="1.5"
android:clickable="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:onClick="callChooseEtat"
android:paddingLeft="5dp"
android:paddingTop="10dp"
android:textStyle="normal" />
<ImageView
android:layout_width="@dimen/stroke_dim"
android:layout_height="fill_parent"
android:background="@color/light_line"
android:contentDescription="@string/img" />
<TextView
android:id="@+id/ent_obervations_val"
style="@android:style/Widget.Holo.Light.EditText"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="2"
android:clickable="true"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:singleLine="true"
android:textColor="@color/black1"
android:textSize="@dimen/mis_item_size" />
<ImageView
android:layout_width="@dimen/stroke_dim"
android:layout_height="fill_parent"
android:background="@color/light_line"
android:contentDescription="@string/img" />
<LinearLayout
android:id="@+id/imageLayout"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true"
android:gravity="center"
android:onClick="callCameraInList" >
<ImageView
android:id="@+id/photoElement_ImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:contentDescription="@string/img"
android:src="@drawable/photo_img" />
</LinearLayout>
<ImageView
android:layout_width="@dimen/stroke_dim"
android:layout_height="fill_parent"
android:background="@color/light_line"
android:contentDescription="@string/img" />
<EditText
android:id="@+id/trouElement_EditText"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:hint="@string/zero"
android:inputType="number"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:singleLine="true"
android:textColor="@color/black1"
android:textSize="@dimen/mis_item_size" />
<ImageView
android:layout_width="@dimen/stroke_dim"
android:layout_height="fill_parent"
android:background="@color/light_line"
android:contentDescription="@string/img" />
<TextView
android:id="@+id/actionElement_TextView"
style="@android:style/Widget.Holo.Light.EditText"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:clickable="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:singleLine="true"
android:textColor="@color/black1"
android:textSize="@dimen/mis_item_size" />
<ImageView
android:layout_width="@dimen/stroke_dim"
android:layout_height="fill_parent"
android:background="@color/light_line"
android:contentDescription="@string/img" />
</LinearLayout>
Вы уверены там на самом деле элементы в вашем 'elementsFromXMLList'? также, какова реализация для 'getItem' и' getItemId'? – njzk2
Да getCount() возвращался 30. Но я не переопределял getItem и getItemId, это необходимо? – Guimareshh
Вы вызываете измененный набор данных уведомления (не знаете, что именно он вызвал, так как у меня нет доступа к Eclipse прямо сейчас) на вашем адаптере, когда вы заполняете базовый список? Вы «новый» список где-нибудь вместо того, чтобы очищать и перезаписывать его? если ответ не равен (1) или да (2), это проблема. – kha