Краткое описание новости парсится в виде html тега , я его вывожу в WebView , но дело в том что если я делаю вместе с
Код: Выделить всё
if(convertView==null) {
convertView = mLInflater.inflate(R.layout.item_news, parent, false);
}-----------
новость1
блаблабла
-----------
новость2
блаблабла
блаблабла
-----------
новость3
блаблабла
-----------
т.е где новость 3 осталось пустое место в WebView
подскажите пожалуйста как это можно исправить.
вот код адаптера:
Код: Выделить всё
public class NewsListAdapter extends BaseListAdapter {
protected ArrayList<ItemNews> items;
public NewsListAdapter(Context context, ArrayList<ItemNews> items) {
super(context, items);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView==null) {
convertView = mLInflater.inflate(R.layout.item_news, parent, false);
}
findView(convertView, position);
return convertView;
}
public void findView(View convertView, int position) {
ItemNews news = getItemNews(position);
TextView[] textView = new TextView[4];
WebView webView;
ImageView imageView;
textView[0] = (TextView) convertView.findViewById(R.id.tvText);
textView[1] = (TextView) convertView.findViewById(R.id.tvText1);
textView[2] = (TextView) convertView.findViewById(R.id.tvText2);
textView[3] = (TextView) convertView.findViewById(R.id.tvText3);
webView = (WebView) convertView.findViewById(R.id.tvWeb);
imageView = (ImageView) convertView.findViewById(R.id.ivImage);
setFavoriteImage(news, imageView, position);
setWebView(webView, news);
setClicker(textView[1], news, position);
setViewPubDate(textView[0], news);
textView[2].setText(news.getTime());
textView[3].setVisibility(View.GONE);
}
public void setViewPubDate(TextView textView, ItemNews news) {
String tag = news.getTag();
textView.setText(news.getpubDate());
if (tag.equals(HandleXML.TAG_NO)) {
textView.setVisibility(View.GONE);
} else {
textView.setVisibility(View.VISIBLE);
}
}
public void setFavoriteImage(ItemNews news, ImageView image, int position) {
if (news.getTagFavorite().equals("add")) {
image.setImageResource(R.drawable.favorite_add);
} else {
image.setImageResource(R.drawable.favorite_no);
}
image.setOnClickListener(this);
image.setTag(position);
}
public void setClicker(TextView textClick, ItemNews news, int position) {
textClick.setText(news.getTitle());
textClick.setOnClickListener(this);
textClick.setTag(position);
}
public void setWebView(WebView webView, ItemNews item) {
WebSettings settings = webView.getSettings();
settings.setDefaultTextEncodingName("utf-8");
String url = item.getDescription();
String summaryUrl = "<html><body><font size='3' color='White'>".concat(url).concat("</font></body></html>");
webView.loadDataWithBaseURL(null, summaryUrl, "text/html", "en_US", null);
webView.setBackgroundColor(0);
}
/**
* Opens the new Activity with webviev,when pressing a title news
*/
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.tvText1:
Intent intent = new Intent(mContext, ActivityNews.class);
intent.putExtra("url", (getItemNews((Integer) view.getTag()).getLink()));
mContext.startActivity(intent);
break;
case R.id.ivImage:
ImageView image = (ImageView) view.findViewById(R.id.ivImage);
if (getItemNews((Integer) view.getTag()).getTagFavorite().equals("add")) {
image.setImageResource(R.drawable.favorite_no);
getItemNews((Integer) view.getTag()).setTagFavorite("no");
} else {
image.setImageResource(R.drawable.favorite_add);
getItemNews((Integer) view.getTag()).setTagFavorite("add");
}
break;
}
}
}Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tvText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/colorWhite"
android:textSize="15sp"
android:textStyle="bold"
android:background="@color/search"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tvText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/colorWhite"
android:textSize="17sp"
android:textStyle="bold"
android:clickable="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<WebView
android:id="@+id/tvWeb"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="15">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ivImage"
android:cropToPadding="false"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/tvText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textColor="@color/colorWhite"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textColor="@color/colorWhite"
android:textStyle="bold"
android:background="@color/colorWhite"/>
</LinearLayout>
</LinearLayout>