Xenix Putra Sasongko Xenix Putra Sasongko - 1 year ago 69
Android Question

CustomListview Volley with Image doesn't works in real device

Someone, help me with this problem. i have stuck in 3 days because this problem -_-!

i can make listview with image and text using volley library, its works in emulator (i use genymotion emulator) the image and text show. but when i run it in my device (android Jelly 4.3.0) the listview is empty. the layer is blank (empty). i don't know why.

heres my piece code

public class DaftarBarang_Layout extends Activity{

private List<Produk> produkList = new ArrayList<Produk>();
private ListView listView;
private CustomListAdapter adapter;
private ProgressDialog pDialog;
private ServerRequest serverRequest;
JSONArray member = null;
private static final String url = "";

protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub

listView = (ListView) findViewById(R.id.list);
adapter = new CustomListAdapter(this, produkList);

btnBack = (Button)findViewById(R.id.btnBackDaftarBarang);

// Creating volley request obj
JsonArrayRequest produkReq = new JsonArrayRequest(url,
new Response.Listener<JSONArray>() {
public void onResponse(JSONArray response) {
Log.d("TAG", response.toString());
// Parsing json
for (int i = 0; i < response.length(); i++) {
try {

JSONObject obj = response.getJSONObject(i);
Produk produk = new Produk();
Log.d("TAG", "TAG : " + produk.getNamaProduk());

// adding movie to movies array

} catch (JSONException e) {


// notifying list adapter about data changes
// so that it renders the list view with updated data
}, new Response.ErrorListener() {
public void onErrorResponse(VolleyError error) {
VolleyLog.d("TAG", "Error: " + error.getMessage());


// Adding request to request queue

im sure the url is fine, and image return is

the problem is, why in real device the listview is not show, but in emulator the listview is show..

sorry for my bad english, but thanks anyway.. :)

heres my CustomListAdapter:

public class CustomListAdapter extends BaseAdapter {
private Activity activity;
private LayoutInflater inflater;
private List<Produk> produkItems;
ImageLoader imageLoader = AppController.getInstance().getImageLoader();

public CustomListAdapter(Activity activity, List<Produk> produkItems) {
this.activity = activity;
this.produkItems = produkItems;

public int getCount() {
return produkItems.size();

public Object getItem(int location) {
return produkItems.get(location);

public long getItemId(int position) {
return position;

public View getView(int position, View convertView, ViewGroup parent) {

if (inflater == null)
inflater = (LayoutInflater) activity
if (convertView == null)
convertView = inflater.inflate(R.layout.list_row, null);

if (imageLoader == null)
imageLoader = AppController.getInstance().getImageLoader();
NetworkImageView thumbNail = (NetworkImageView) convertView
TextView title = (TextView) convertView.findViewById(R.id.title);
TextView rating = (TextView) convertView.findViewById(R.id.rating);

// getting movie data for the row
Produk p = produkItems.get(position);

// thumbnail image
thumbNail.setImageUrl(p.getFotoProduk(), imageLoader);

// title

// rating
rating.setText("Harga: " + p.getHargaProduk());

return convertView;

Answer Source

Add this code to your onCreate or init method.

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();

If this doesn't work please post logcat showing warning or error.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download