我正在使用Picasso将我的图像提取到Listview中。然后我使用getIntent()将所有特定数据传递到另一个页面。我能够获得所有数据,但它在图像部分显示错误:
W/System.err: java.io.FileNotFoundException: http://fypestem.com/lecturer/com.squareup.picasso.PicassoDrawable@52a285
W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:238)
虽然错误很明显,但我不知道改变com.squareup.picasso.PicassoDrawable@52a285的其他方法,因为它应该是upload / image.jpg。这是我的代码:
public class lecturer_details_modify extends AppCompatActivity implements View.OnClickListener{
private static final String TAG_ID="lecID";
private static final String TAG_IMAGE="image";
String lecID,lecName,lecPass,lecEmail,lecImage;
TextView tvLecturer_modify1;
EditText etLecturer_modify1,etLecturer_modify2,etLecturer_modify3;
ImageView ivLecturer_modify1;
private int PICK_IMAGE_REQUEST = 1;
private Bitmap bitmap;
JSONParser jsonParser = new JSONParser();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lecturer_details_modify);
findViewById();
Intent i=getIntent();
lecID=i.getStringExtra(TAG_ID);
lecImage=i.getStringExtra(TAG_IMAGE);
@Override
protected Bitmap doInBackground(String... params) {
String add="http://fypestem.com/lecturer/" +lecImage;
URL url=null;
Bitmap image=null;
try {
url = new URL(add);
image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return image;
}
}
GetImage gi=new GetImage();
gi.execute(lecImage);
}
答案 0 :(得分:0)
import java.lang.reflect.*;
import java.util.*;
public static Object nArray(int n) {
int[]dim = new int [n];
Arrays.fill(dim, n);
return Array.newInstance(int.class,dim);
}
因为这样的原因它可能会给您""
crash
答案 1 :(得分:0)
您遇到此类错误的原因是根据您获得的日志,图像路径不正确
19cb18547031800eacada887edb7f02e.jpg
和base url
图片的fystem.com/upload/
是http://fystem.com/upload/19cb18547031800eacada887edb7f02e.jpg
合并这些路径所在的完整字符串
wktohtml
不幸的是,此路径上没有图像,您可以在浏览器上进行测试。
希望这会对你有所帮助。
答案 2 :(得分:0)
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// PASS THIS WAY
String lec_Image="fystem.com/lecturer/"+lecturers.get(position).getImage();
String lec_ID=((TextView) view.findViewById(R.id.lec_ID)).getText().toString();
Intent in=new Intent(getApplicationContext(),lecturer_details_modify.class);
in.putExtra(TAG_IMAGE,lec_Image);
in.putExtra(TAG_NAME,lec_Name);
in.putExtra(TAG_ID,lec_ID);
startActivity(in);