Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 图像显示不正确_Java_Android - Fatal编程技术网

Java 图像显示不正确

Java 图像显示不正确,java,android,Java,Android,我正在制作一个android应用程序,它使用懒人列表显示图像和文本 我从服务器上的json获取数据。当我在mysql数据库中手动输入一些数据和图像路径时,这些图像会在应用程序中正确显示 但是,当我从手机摄像头拍摄图像并上传该图像时,它会在mysql数据库中正确插入路径,但不会显示在我的应用程序中 有人能告诉我为什么我有这个问题吗?我的日志中没有错误 还有其他人有这个问题吗?如果是,那么您是如何解决的?请帮帮我 但当我从手机摄像头拍摄图像并上传该图像时,它确实在mysql数据库中正确插入了所有路

我正在制作一个android应用程序,它使用懒人列表显示图像和文本

我从服务器上的
json
获取数据。当我在mysql数据库中手动输入一些数据和图像路径时,这些图像会在应用程序中正确显示

但是,当我从手机摄像头拍摄图像并上传该图像时,它会在mysql数据库中正确插入路径,但不会显示在我的应用程序中

有人能告诉我为什么我有这个问题吗?我的日志中没有错误

还有其他人有这个问题吗?如果是,那么您是如何解决的?请帮帮我


但当我从手机摄像头拍摄图像并上传该图像时,它确实在mysql数据库中正确插入了所有路径,但它仍然没有显示在我的应用程序中

新图像和旧图像的URL相同吗


如果是这样,则可能是图像缓存的情况。ImageLoader使用URL作为键缓存图像。。。。清除应用程序数据后重试。

@omidnazifi I在上面添加了几个文件。请检查设备重新启动后此问题是否仍然存在。我是说你试过了吗。捕获摄像头图像,保存在数据库中,重新启动设备,然后查看是否显示图像。请澄清,您是否将图像存储在数据库中或sd卡上的图像路径?如何将图像存储为Base64字符串?什么是
imageLoader
DisplayImage
做什么?能否显示保存到DB的图像路径(用于相机图像)?请提供“手动输入”到数据库的路径以及应用程序生成的路径(不工作)的示例。此外,文件实际存在于何处?您可以手动清除它…(设置>应用程序>应用程序>清除缓存),但如果它解决了问题,则您需要更改您的Web服务,以便更新图像应具有不同的url…它具有相同的url,但图像名称不同。我的意思是一个图像url是
http://example.com/appname/photos/useridfolder/image1.jpg
第二个图像url是
http://example.com/appname/photos/useridfolder/image2.jpg
。你认为它是同一个url吗?
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home_list);

    inboxList = new ArrayList<HashMap<String, String>>();

    List<String> profile_photo = new ArrayList<String>();
    List<String> userName = new ArrayList<String>();
    List<String> place = new ArrayList<String>();

    list=(ListView)findViewById(R.id.list);
    //adapter=new LazyAdapter(this, tS, mTitles);
    list.setAdapter(adapter);

    /********************************/

    JSONObject json = userFunctions.homeData();

    Log.e("Data", json.toString());

    // Check your log cat for JSON reponse
    // Log.d("Inbox JSON: ", json.toString());

    try {
        data = json.getJSONArray("data");
        Log.d("inbox array: ", data.toString());
        // looping through All messages
        for (int i = 0; i < data.length(); i++) {
            JSONObject c = data.getJSONObject(i);

            // Storing each json item in variable
            String uid = c.getString("uid");
            String name = c.getString("name");
            String success = c.getString("success");
            String profile_img = c.getString("profile_photo");
            //String date = c.getString(TAG_DATE);

            JSONObject places = c.getJSONObject(TAG_PLACES);
            String place_photo = places.getString(TAG_PLACE_IMG);

            Log.e("place_photo", place_photo);
            // creating new HashMap
            HashMap<String, String> map = new HashMap<String, String>();

            // adding each child node to HashMap key => value
            map.put("uid", uid);
            map.put("name", name);
            map.put("success", success);
            map.put("profile_image", profile_img);

            profile_photo.add(profile_img);
            userName.add(name);
            place.add(place_photo);
            // adding HashList to ArrayList
            inboxList.add(map);
        }

        profile_image = new String[profile_photo.size()];
        user_name = new String[userName.size()];
        place_image = new String[(place.size())];

        profile_photo.toArray(profile_image);
        userName.toArray(user_name);
        place.toArray(place_image);
        adapter = new LazyAdapter(this, profile_image, user_name, place_image);
        list.setAdapter(adapter);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    /*******************************/
}
public class LazyAdapter extends BaseAdapter {

private Activity activity;
private String[] data;
private String[] name;
private String[] place_photo;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader; 

public LazyAdapter(Activity a, String[] d, String[] username, String[] place_image) {
    activity = a;
    data = d;
    name = username;
    place_photo = place_image;
    //Log.e("path", d.toString());
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader=new ImageLoader(activity.getApplicationContext());
}

public int getCount() {
    return data.length;
}

public Object getItem(int position) {
    return position;
}

public long getItemId(int position) {
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;
    if(convertView==null)
        vi = inflater.inflate(R.layout.home_list_item, null);

    //TextView text=(TextView)vi.findViewById(R.id.text);
    TextView title = (TextView)vi.findViewById(R.id.username);
    ImageView image=(ImageView)vi.findViewById(R.id.image);
    ImageView place=(ImageView)vi.findViewById(R.id.place);
    //text.setText("item "+position);
    title.setText(name[position]);
    imageLoader.DisplayImage(data[position], image);
    imageLoader.DisplayImage(place_photo[position], place);
    return vi;
}
}