2016-03-24 9 views
1

Ich bekomme ein zusätzliches Symbol beim Hinzufügen von ImageView in einer ListView wie unten gezeigt. Was ist das und wie kann ich es entfernen? enter image description hereImageView in ListView gibt zusätzliches Bild

In meinem Inhalt es zeigt auch, und wenn sie ausgewählt es unterstreicht die Image hier gezeigten enter image description here

Der Code xml ist hier:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="anaxin.newshellas.Feed" 
    tools:showIn="@layout/activity_feed"> 

    <ListView 
     android:choiceMode="singleChoice" 
     android:listSelector="@android:color/darker_gray" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/feedView" 
     android:layout_centerVertical="true" 
     android:layout_centerHorizontal="true" 
     android:clickable="false" /> 
    <TextView 
     android:id="@+id/textTop" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="16sp" 
     android:textStyle="bold" 
     /> 
    <TextView 
     android:id="@+id/textBot" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="12sp" 
     android:layout_below="@+id/textTop" 
     /> 
    <ImageView 
     android:layout_below="@+id/textTop" 
     android:layout_alignParentRight="true" 
     android:id="@+id/image" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/image" 
     /> 
</RelativeLayout> 

Ich benutze einen SimpleAdapter mit zwei Reihen (TEXTTOP , TextBot), um mein listView wie folgt zu füllen:

final SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.content_feed, 
       new String[]{"First Line", "Second Line"}, 
       new int[]{R.id.textTop, R.id.textBot}) { 
      public View getView(int position, View convertView, ViewGroup parent) { 
       View view = super.getView(position, convertView, parent); 
       return view; 
      } 
     }; 

Und ich n Methode zum Hinzufügen von Elementen dieser Teil

+0

Welches Bild wird mit 'android: src =" @ drawable/image "'? Hast du versucht, das zu entfernen? –

+0

Ich denke, listView Artikellayout ist anders .. Dieses Layout ist anders. Entfernen oder kommentieren Sie ImageView in diesem Layout. –

+0

Haben Sie auch eine Bildansicht innerhalb des Adapters? entferne die Bildansicht in diesem Layout und behalte die, die du in dem Adapter hast –

Antwort

1

allererst nicht Sie vermischen Sie ListView und andere Elemente wie TextView und ImageView, die in der einzelnen Artikel Layout sein sollte. Aus diesem Grund sehen Sie mehrere Bilder in einer einzelnen Liste.

Und noch etwas zu bemerken ist Ihr android:layout_below="@+id/textTop" Attribut in Konflikt gerieten in ImageView und TextView als gut, so empfehle ich Ihnen, dass auch zu beheben.

Rest der Codes sind gut genug !!

1

Sie haben eine zusätzliche ImageView und 2 zusätzliche TextViews in Ihrer Layoutdatei. Diese sollten sich in der Layoutdatei Ihres Listenadapters befinden und nicht im Layout, das die Listenansicht selbst enthält. Versuchen Sie, diese zusätzlichen Ansichten zu entfernen, das könnte Ihr Problem

0

entfernen alle Inhalte in der Liste Ansicht wie

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
tools:context="anaxin.newshellas.Feed" 
tools:showIn="@layout/activity_feed"> 
<ListView 
    android:choiceMode="singleChoice" 
    android:listSelector="@android:color/darker_gray" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/feedView" 
    android:layout_centerVertical="true" 
    android:layout_centerHorizontal="true" 
    android:clickable="false" /> 

Sie lösen nicht brauchen sie

Verwandte Themen