jeudi 21 mai 2015

TextView is not acquiring space of ImageView

I am trying to get News from one site. Some articles have images. Here is my problem: some article doesn't have images so i want remove that Imageview for that row and title textview should acquire that space. I tried to implement it in BaseAdapter but setvisibility(View.Gone) is not working i guess.

Here is my layout file:

<!-- Thumbnail Image -->
<com.android.volley.toolbox.NetworkImageView
    android:id="@+id/thumbnail"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_alignParentLeft="true"
    android:layout_marginRight="8dp" />

<!-- News Title -->
<TextView
    android:id="@+id/title"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="@dimen/title"
    android:ellipsize="end"
    android:textStyle="bold"
    android:layout_alignTop="@+id/thumbnail"
    android:layout_toRightOf="@+id/thumbnail"/>

Here is my implementation in base adapter:

  NetworkImageView thumbNail = (NetworkImageView) convertView
            .findViewById(R.id.thumbnail);
    TextView title = (TextView) convertView.findViewById(R.id.title);

    // getting movie data for the row
    Movie m = movieItems.get(position);

    if(m.getThumbnailUrl() == null)
    {

     thumbNail.setVisibility(View.GONE); //Not working

    }
    else {
        thumbNail.setImageUrl(m.getThumbnailUrl(), imageLoader);
    }

And current output is: I want that blank space of Imageview to be used by textview.

Example

Aucun commentaire:

Enregistrer un commentaire