を使用してホーム画面ウィジェットに連絡先の写真を表示しようとしていますRemoteViews.setImageViewUri()
が、何も表示されません。
写真のURIをログに記録しましたが、正しいですcontent://com.android.contacts/contacts/293/photo
これが私のgetViewAt
方法です:
// Create and populate the View to display at the given index.
public RemoteViews getViewAt(int index) {
// Create a view to display at the required index.
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.item_layout);
// Populate the view with contact name.
rv.setTextViewText(R.id.name, items.get(index).getString("first_name"));
//check if we have a photo set
if (items.get(index).getString("photo_url") != null) {
Log.i("parsed uri", String.valueOf(Uri.parse(items.get(index).getString("photo_url"))));
rv.setImageViewUri(R.id.photo_url, Uri.parse(items.get(index).getString("photo_url")));
}
// Create an item-specific fill-in Intent that will populate
// the Pending Intent template created in the App Widget Provider (GridWidgetProvider).
Intent fillInIntent = new Intent();
fillInIntent.putExtra(Intent.EXTRA_TEXT, items.get(index));
rv.setOnClickFillInIntent(R.id.name, fillInIntent);
return rv;
}
連絡先の名前は表示されますが、写真はありません...
理由はありますか?ありがとう
編集:ImageViewのxml:
<ImageView
android:id="@+id/photo_url"
android:layout_width="match_parent"
android:layout_height="125dp"
android:layout_above="@id/name"
android:gravity="center"
android:background="#FFFF0000"
/>