@Override protected View realGetView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = getLayoutInflater().inflate(R.layout.wrapper_news_main_list_item, parent, false); } TextView tvTitle = ViewUtils.get(convertView, R.id.title); TextView tvSource = ViewUtils.get(convertView, R.id.source); TextView tvDate = ViewUtils.get(convertView, R.id.date); ImageView ivNewsPic = ViewUtils.get(convertView, R.id.newsPic); News news = realGetItem(position); tvTitle.setText(news.getTitle()); tvSource.setText(news.getSource()); tvDate.setText(news.getDate()); if (TextUtils.isEmpty(news.getPhotoUrl())) { ivNewsPic.setVisibility(View.GONE); } else { ivNewsPic.setVisibility(View.VISIBLE); mImageLoader.displayImage(news.getPhotoUrl(), ivNewsPic, mOptions); } return convertView; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.wrapper_news_main); Intent intent = getIntent(); if (intent != null) { mTitle = intent.getStringExtra("title"); mKeyword = intent.getStringExtra("keyword"); } if (!TextUtils.isEmpty(mTitle)) { setActionBarTitle(mTitle); } mImageLoader = ImageLoader.getInstance(); mOptions = DisplayImageBuilder.getDefault() .cacheOnDisc(true) .considerExifParams(true) .bitmapConfig(Bitmap.Config.RGB_565) .displayer(new RoundedBitmapDisplayer(6)) .build(); doSearch(mKeyword, mPage); }