【发布时间】:2015-10-14 10:12:39
【问题描述】:
我正在尝试从 google place 的 json 响应提供的 url 加载图像,并将其放入一个 Imageview 布局中,该布局将在单击标记时显示。我在运行时或调试中没有错误,但图像不会显示在 Imageview 上。有什么可能导致这种情况吗?
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/places"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="horizontal"
android:background="@drawable/mapinfoborder">
<ImageView
android:id="@+id/place_badge"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:adjustViewBounds="true" />
<TextView
android:id="@+id/place_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textColor="#ffffffff"
android:layout_below="@+id/place_badge"
android:paddingTop="5dp"
android:textSize="20dp"
android:gravity="center"
android:text="TitlePlaceHolder"/>
<TextView
android:id="@+id/place_snippet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/place_title"
android:paddingTop="5dp"
android:textColor="#ffffffff"
android:textSize="16dp"
android:gravity="center"
android:text="SnippetPlaceHolder"/>
</RelativeLayout>
在我的活动中调用它:
View v = inflater.inflate(R.layout.places_layout, null);
placeImage = (ImageView) v.findViewById(R.id.place_badge);
...
Picasso.with(getApplicationContext())
.load(markerPlaces.get(marker.getId())).placeholder(R.drawable.bus)
.into(placeImage);
我再一次没有收到任何错误,所以我真的没有可用的 logcat 可以提供。 感谢任何 cmets/想法/建议。
【问题讨论】:
-
查看stackoverflow.com/a/17939885/4826114 进行错误处理
-
我认为这个问题是,您创建了一个新视图,但您没有将其附加到活动视图。还是你在...?
-
感谢您的回复!我弄清楚发生了什么事。不是图像没有加载,它只是加载缓慢。我正在尝试优化它,这可能是另一个线程上的另一个问题!
标签: java android image imageview picasso