数据未添加到列表视图中。它显示没有图像视图的错误,它将其图像的ID添加到列表视图但是当我将图像字符串传递给图像视图时,它会给出错误
JSONObject json_data = new JSONObject(result);
jsonarray=json_data.getJSONArray("image");
for(int i=0;i<jsonarray.length();i++)
{
JSONObject c=jsonarray.getJSONObject(i);
id=c.getString("id");
image=c.getString("image");//receiving the json blob image data
byte[] decodedString = Base64.decode(image, Base64.DEFAULT);
String imaged = new String(decodedString);
//bitmap= BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
//////
HashMap<String,String> mydata=new HashMap<String, String>();
mydata.put("id", id);
mydata.put("image",imaged);
arraylist.add(mydata);
Log.w("id", id);
Log.e("11", "json data");
}
protected void onPostExecute(String result) {
// TODO Auto-generated method stub
String from[]={"id",,"image"};
int to[]={R.id.id,R.id.pimage};
smp=new
SimpleAdapter(prescriptionlist.this,arraylist,R.layout.prescription_list_row,from,to);
patientlistdata.setAdapter(smp);
}
图像的json数据,而mysql中的图像类型是blob
{"image": [{"id":"1","image":"\/9j\/4AAQSkZJRgABAQAAAQABAAD\/........
{"id":"2","image":"\/9j\/4AAQSkZJRgABA.........
程序的logcat
10-10 16:35:40.470: E/AndroidRuntime(3268): FATAL EXCEPTION: main
10-10 16:35:40.470: E/AndroidRuntime(3268): Process: com.example.drprescription, PID: 3268
10-10 16:35:40.470: E/AndroidRuntime(3268): java.lang.NullPointerException
10-10 16:35:40.470: E/AndroidRuntime(3268): at
android.widget.SimpleAdapter.getCount(SimpleAdapter.java:93)
10-10 16:35:40.470: E/AndroidRuntime(3268): at
android.widget.ListView.setAdapter(ListView.java:480)
10-10 16:35:40.470: E/AndroidRuntime(3268): at
com.example.drprescription.prescriptionlist$viewprescription.onPostExecute(prescriptionlist.java:157) 10-10 16:35:40.470: E/AndroidRuntime(3268): at
com.example.drprescription.prescriptionlist$viewprescription.onPostExecute(prescriptionlist.java:1)
10-10 16:35:40.470: E/AndroidRuntime(3268): at
android.os.AsyncTask.finish(AsyncTask.java:632)
10-10 16:35:40.470: E/AndroidRuntime(3268): at
android.os.AsyncTask.access$600(AsyncTask.java:177)
10-10 16:35:40.470: E/AndroidRuntime(3268): at
android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
10-10 16:35:40.470: E/AndroidRuntime(3268): at
android.os.Handler.dispatchMessage(Handler.java:102)
10-10 16:35:40.470: E/AndroidRuntime(3268): at android.os.Looper.loop(Looper.java:136)
10-10 16:35:40.470: E/AndroidRuntime(3268): at
android.app.ActivityThread.main(ActivityThread.java:5017)
10-10 16:35:40.470: E/AndroidRuntime(3268): at java.lang.reflect.Method.invokeNative(Native
Method)
10-10 16:35:40.470: E/AndroidRuntime(3268): at
java.lang.reflect.Method.invoke(Method.java:515)
10-10 16:35:40.470: E/AndroidRuntime(3268): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
10-10 16:35:40.470: E/AndroidRuntime(3268): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
10-10 16:35:40.470: E/AndroidRuntime(3268): at dalvik.system.NativeStart.main(Native Method)