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.
When I try with ViewHolder for smooth transition i am unable to implement this logic:
if (position==-1)
{
viewHolder.thumbnail.setVisibility(View.GONE);
}
else
{
viewHolder.thumbnail.setImageUrl(news.getThumbnailUrl(), imageLoader);
}