タイトルが少し乱雑であることは知っていますが、ここに問題があります....私の目標は、タイトルを取得し、サムネイル URL を使用して YouTube チャンネルの動画のサムネイルを listView に描画することです...これまでのところ、私は動画タイトルをきちんと表示するためのtextViewですが、とにかくサムネイルが描画できませんでした.....ちなみに、json / sqliteのクラスは適切に行われており、データを適切に取得できるので、心配する必要はありません。 ..私を悩ませる唯一のことは、サムネイルが表示されないことです.imageViewはアプリの空のスペースとして表示されます....
これが私のコードです。手を貸してください。どうも
これは、アクティビティの 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>