gpt4 book ai didi

android - 使用 Android Studio 显示错误的 Web ListView 图像

转载 作者:太空狗 更新时间:2023-10-29 16:14:50 26 4
gpt4 key购买 nike

我有一个 listView,我在其中显示此人的个人资料图片(一种学校社交媒体),并将这些图片的链接连同他们的姓名和其他 2 个参数一起存储在 SQL 数据库中.

这是我的自定义适配器:

class customAdapter extends ArrayAdapter<String> {
public customAdapter(Context context, String[] friends) {
super(context, R.layout.customrow, friends);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
MyDBHandler dbHandler = new MyDBHandler(getContext(), null, null, 1);
Product product;
LayoutInflater myinfl = LayoutInflater.from(getContext());
View customview = myinfl.inflate(R.layout.customrow, parent, false);
String singlefooditem = getItem(position);
TextView name = (TextView)customview.findViewById(R.id.rowText);
ImageView img = (ImageView)customview.findViewById(R.id.profilePic);
product = dbHandler.findProductName(singlefooditem);
try {
URL url = new URL(product.getImage());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();

Bitmap myBitmap = BitmapFactory.decodeStream(input);
img.setImageBitmap(myBitmap);
}catch (IOException e){

}

name.setText(singlefooditem);
return customview;
}

那是我的logcat:

            at android.view.View.measure(View.java:17479)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5364)
at android.support.v7.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:444)
at android.view.View.measure(View.java:17479)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5364)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:17479)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5364)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:17479)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5364)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2532)
at android.view.View.measure(View.java:17479)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2262)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1391)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1590)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1249)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6585)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:803)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:573)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:789)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5586)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)

最佳答案

我怀疑堆栈跟踪不包括真正的错误,这似乎是您试图在主 (UI) 线程上执行网络 Activity ,这是一个很大的禁忌。在新线程中执行此工作,或使用 Android ImageManager类为您完成所有艰苦的工作。

关于android - 使用 Android Studio 显示错误的 Web ListView 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31880506/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com