我知道标题有点凌乱,但这是问题.... 我的目标是检索标题,并使用缩略图URL将我的youtube频道视频的缩略图绘制到listView ... 到目前为止,我有textView正确显示视频标题,但缩略图无论如何也无法绘制.....顺便说一句,我已经正确完成了json / sqlite的东西,他们可以正确地检索数据,所以我不不得不担心...唯一困扰我的是缩略图不会显示,imageView在应用程序中显示为空白区域....
这是我的代码,请帮我一把。 THX
这是活动的on create方法......
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] uiBindFrom = { TutListDatabase.COL_TITLE, TutListDatabase.COL_THUMBNAIL };
int[] uiBindTo = { R.id.title, R.id.thumbnail };
getLoaderManager().initLoader(TUTORIAL_LIST_LOADER, null, this);
adapter = new SimpleCursorAdapter(
getActivity().getApplicationContext(), R.layout.list_item,
null, uiBindFrom, uiBindTo,
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
adapter.setViewBinder(new MyViewBinder());
setListAdapter(adapter);
}
这个是将东西放到listView上的私有类...
private class MyViewBinder implements SimpleCursorAdapter.ViewBinder{
@Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
int viewId = view.getId();
switch(viewId){
case R.id.title:
TextView titleTV = (TextView)view;
titleTV.setText(cursor.getString(columnIndex));
break;
// it is not displaying any thumbnail in app....
case R.id.thumbnail:
ImageView thumb = (ImageView) view;
thumb.setImageURI(Uri.parse(cursor.getString(columnIndex)));
break;
}
return false;
}
}
这是xml布局文件......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:id="@+id/thumbnail"
android:layout_width="101dp"
android:layout_height="101dp"
android:src="@drawable/icon" />
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dp"
android:textSize="24dp" />
</LinearLayout>