I have an application which uses json to get links and texts and now i want to load the image from the downloaded url (by json) in the Listview.
I can load texts in the listview but i can load images!
PLZ help me i have spended 2 days for this and searched,... but no chance! I really need your help! anyone can help me i'll make a great thanks to him in application. PLZZZ help me.
MY CODE :
package rappage.rapfarsi.media.appteam.rapnews;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
 import android.content.Intent;
 import android.graphics.Bitmap;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.support.v4.app.ListFragment;
 import android.util.Log;
 import android.view.LayoutInflater;
     import android.view.View;
     import android.view.ViewGroup;
   import android.widget.ListAdapter;
  import android.widget.ListView;
 import android.widget.SimpleAdapter;
import android.widget.TextView;
 import android.widget.Toast;
import org.apache.http.NameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
 import org.json.JSONObject;
import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
import rappage.rapfarsi.media.appteam.Articlectivity;
 import rappage.rapfarsi.media.appteam.Main;
  import rappage.rapfarsi.media.appteam.R;
  import rappage.rapfarsi.media.appteam.json.JSONParser;
public class tab2 extends ListFragment {
static final String url_all_products = "http://normaluse.persianrapapp021.ml/article/get_all_products.php";
// Progress Dialog
private ProgressDialog pDialog;
// Creating JSON Parser object
JSONParser jParser = new JSONParser();
ArrayList<HashMap<String, String>> productsList;
// url to get all products list
final String TAG_SUCCESS = "success";
final String TAG_RAPNEWS = "article";
final String TAG_PID = "pid";
final String TAG_TITLE = "title";
final String TAG_PIC = "pic";
final String TAG_WRITER = "writer";
Bitmap bmp;
// JSON Node names
// products JSONArray
JSONArray rapnews = null;
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.tab_2, container, false);
    final View rootView = super.onCreateView(inflater, container, savedInstanceState);
    // Hashmap for ListView
    productsList = new ArrayList<HashMap<String, String>>();
    // Loading products in Background Thread
    /**
     * Background Async Task to Load all product by making HTTP Request
     * */
    try {
        new LoadAllProducts().execute();
    }catch (Exception e)
    {
        final AlertDialog.Builder dlgAlert = new AlertDialog.Builder(getActivity());
        dlgAlert.setMessage("لطفا اینترنت خودرا چک کنید! یا ممکن است سرور از دسترس خارج شده باشد ، برای اخبار اپدیت و مشکلات به ویکی رپ مراجعه کنید!");
        dlgAlert.setTitle("Connection Error!");
        dlgAlert.setNegativeButton("باشه گرفتم", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                startActivity(new Intent(getActivity() , Main.class));
            }
        });
        dlgAlert.create().show();
    }
    return v;
}
class LoadAllProducts extends AsyncTask<String, String, String> {
    /**
     * Before starting background thread Show Progress Dialog
     */
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(getActivity());
        pDialog.setMessage("Loading, Wait...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();
    }
    /**
     * getting All products from url
     */
    protected String doInBackground(String... args) {
        // Building Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        // getting JSON string from URL
        JSONObject json = jParser.makeHttpRequest(url_all_products, "GET", params);
        // Check your log cat for JSON reponse
        Log.d("All Products: ", json.toString());
        try {
            // Checking for SUCCESS TAG
            int success = json.getInt(TAG_SUCCESS);
            if (success == 1) {
                // products found
                // Getting Array of Products
                rapnews = json.getJSONArray(TAG_RAPNEWS);
                // looping through All Products
                for (int i = 0; i < 11; i++) {
                    JSONObject c = rapnews.getJSONObject(i);
                    // Storing each json item in variable
                    String id = c.getString(TAG_PID);
                    String name = c.getString(TAG_TITLE);
                    String pic = c.getString(TAG_PIC);
                    // creating new HashMap
                    HashMap<String, String> map = new HashMap<String, String>();
                    // adding each child node to HashMap key => value
                    map.put(TAG_PID, id);
                    map.put(TAG_TITLE, name);
                    map.put(TAG_PIC, pic);
                    // adding HashList to ArrayList
                    productsList.add(map);
                }
            } else {
                // no products found
                // Launch Add New product Activity
                Intent i = new Intent(getActivity().getApplicationContext(),
                        Main.class);
                // Closing all previous activities
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(i);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * After completing background task Dismiss the progress dialog
     * *
     */
    protected void onPostExecute(String file_url) {
        // dismiss the dialog after getting all products
        pDialog.dismiss();
        // updating UI from Background Thread
        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                /**
                 * Updating parsed JSON data into ListView
                 * */
                ListAdapter adapter = new SimpleAdapter(
                        getActivity(), productsList,
                        R.layout.list_item, new String[]{TAG_PID,
                        TAG_TITLE},
                        new int[]{R.id.pid, R.id.txttitle}
                );
                setListAdapter(adapter);
            }
        });
    }
}
public void onListItemClick(ListView l, View v, int position, long id) {
    Toast.makeText(getActivity().getApplicationContext(), "Loading, Please Wait...",
            Toast.LENGTH_LONG).show();
    String pid = ((TextView) v.findViewById(R.id.pid)).getText()
            .toString();
    // Starting new intent
    Intent in = new Intent(getActivity(),Articlectivity.class);
    // sending pid to next activity
    in.putExtra(TAG_PID, pid);
    // starting new activity and expecting some response back
    startActivity(in);
}
}
I WANT TO LOAD IMAGES ATLEAST IN THIS BASE... OR ANYOTHER THING...
 
     
    