나는 사용자 지정 배열 어댑터가 있고 ListView에 이미지보기를 갖고 싶습니다. 2.2 및 2.3.X 장치에서만 발생합니다. 내가 목록을로드 할 때ListView with a image
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/place_category_icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_marginRight="8dp"
android:background="@drawable/photo1"
android:scaleType="centerCrop" >
</ImageView>
<TextView
android:id="@+id/place_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/list_timestamp"
android:ellipsize="end"
android:singleLine="true"
android:text="Harsha Mallikarjun Vantagudi"
android:textStyle="bold" >
</TextView>
<TextView
android:id="@+id/place_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="6dp"
android:paddingLeft="30dp"
android:singleLine="true"
android:text="2 hours" >
</TextView>
</LinearLayout>
을 다음과 같이
내 행 템플릿입니다. 이미지가 표시되지만 텍스트를 스크롤하려고하면 텍스트가 사라지고 다시 사라집니다. 내가 잘못, 내가 인플레이터 :)를 사용하고 있었다
public class PlacesListAdapter extends ArrayAdapter<Place> implements
Filterable {
public Context context;
private List<Place> places;
public PlacesListAdapter(Context context, List<Place> places) {
super(context, R.layout.list_item_place, places);
this.context = context;
this.places = places;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater;
inflater = LayoutInflater.from(getContext());
view = inflater.inflate(R.layout.list_item_place, null);
}
Place place = places.get(position);
if (place != null) {
TextView place_title = (TextView) view
.findViewById(R.id.place_name);
TextView place_distance = (TextView) view
.findViewById(R.id.place_distance);
if (place_title != null) {
place_title.setText(place.getPlaceName());
}
if (place_distance != null) {
place_distance.setText(place.getPlaceDistance());
}
}
return view;
}
}
좋은 스크린 샷이지만 어떤 코드는 무엇입니까? –
@ K-ballo가 추가되었습니다. 이미지를 제거하면 잘 작동합니다. –
내가 어떻게하는지 모르겠다.하지만 getView에서 인플레터를 사용하지 않고 아무런 문제가 없다. 어쩌면해볼 가치가있다. –