title: ListView Android cannot display item
body: <p>I just tried custom Listview android from parsing JSON (JSON is okay without problems), it is very strange for me, because I can get the item but Listview doesnt display the item, actually I am confused. I have checked with the using method Toast, it toasts the item, but it cannot display, here my source :
  ListView Adapter :</p>
  
  <pre><code>import java.net.URL;
  import java.util.ArrayList;
  
  import android.app.Activity;
  import android.content.Context;
  import android.graphics.Color;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.BaseAdapter;
  import android.widget.ImageView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class ListViewAdapter extends BaseAdapter{
      private static ArrayList&lt;ItemClass&gt; DataProcessorResult;
      private LayoutInflater myInflater;
      Context mycontext;
  
      public ListViewAdapter(Context context, ArrayList&lt;ItemClass&gt; results) {
          DataProcessorResult = results;
          myInflater = LayoutInflater.from(context);
      }
  
      @Override
      public int getCount() {
          // TODO Auto-generated method stub
          //Log.d("count", String.valueOf(DataProcessorResult.size()));
          return DataProcessorResult.size();
      }
  
      @Override
      public Object getItem(int position) {
          // TODO Auto-generated method stub
          return DataProcessorResult.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          // TODO Auto-generated method stub
          return position;
      }   
  
      @Override
      public View getView(final int position, View convertView, ViewGroup parent) 
      { 
          final ViewHolder holder; 
          final Context mycontext=parent.getContext();       
  
          if(convertView == null) {
              convertView = myInflater.inflate(R.layout.custom_viewproduct, null);
              holder = new ViewHolder();
              holder.txtItemCode = (TextView) convertView.findViewById(R.id.title);
              holder.txtHarga = (TextView) convertView.findViewById(R.id.harga);
              holder.imgitem= (ImageView) convertView.findViewById(R.id.imgitem);
              convertView.setTag(holder);            
          }else{
              holder = (ViewHolder) convertView.getTag();
          }
  
          holder.txtItemCode.setText(DataProcessorResult.get(position).getTitle());
          holder.txtHarga.setText(DataProcessorResult.get(position).getHarga());
  
          Toast.makeText(mycontext, DataProcessorResult.get(position).getTitle(), Toast.LENGTH_SHORT).show();
  
          if (position % 2 == 1) {convertView.setBackgroundColor(Color.WHITE);} else {convertView.setBackgroundColor(Color.rgb(208,212,208)); }        
          return convertView;
      } 
      static class ViewHolder { 
          TextView txtItemCode;
          TextView txtHarga;
          TextView txtSize;
          TextView txtPrice;
          ImageView imgitem;
      }
  
  }
  </code></pre>
  
  <p>my main program :</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.Hashtable;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.app.Dialog;
  import android.app.ProgressDialog;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ListView;
  import android.widget.Toast;
  
  public class Saletab extends Activity {
      public static String BaseUrl="";
      final int PROGRESS_DIALOG=1;
  
      ViewConnection connection;
  
      ArrayList&lt;ItemClass&gt; itemlist=new ArrayList&lt;ItemClass&gt;();           
      ArrayList&lt;ItemClass&gt; arritem=new ArrayList&lt;ItemClass&gt;();    
      ArrayList&lt;String&gt; arritemcategory;
  
      ListView listview;
      //ListViewAdapter ListViewAdapter;
  
      @Override
      protected Dialog onCreateDialog(int id) {
          switch(id)
          {
          case PROGRESS_DIALOG:
              ProgressDialog progress =new ProgressDialog(this);
              progress.setMessage("Loading");
              progress.setTitle("Initializing Please Wait");          
              progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
              progress.setProgress(0);
              progress.setMax(100);           
              return progress;
          }
          return super.onCreateDialog(id);
      }
  
      private class GetDeptAyncTask extends AsyncTask&lt;Hashtable&lt;String,String&gt;,Void,String&gt; {             
          @Override
          protected void onPreExecute() {
              showDialog(PROGRESS_DIALOG);
              super.onPreExecute();
          } 
          @Override
          protected String doInBackground(Hashtable&lt;String, String&gt;... params) 
          {
              // TODO Auto-generated method stub
              Hashtable ht=params[0];         
  
              String json=HelperHttp.getJSONResponseFromURL(BaseUrl, ht);
              if(json!=null) {
                  parseJsonString(itemlist,json); 
              }else{
                  return "No internet access";
              }
              return json;
          }               
  
          protected void parseJsonString(ArrayList&lt;ItemClass&gt; itemlistjs,String json){
              try {               
                  JSONObject jsonObj = new JSONObject(json);
                  JSONArray array = jsonObj.getJSONArray("listitem");             
  
                  ItemClass.setlength(array.length());
  
                  for (int i=0;i&lt;array.length();i++){
                      JSONObject js=array.getJSONObject(i);
  
                      ItemClass item=new ItemClass(js.getString("IdProperty"),
                              js.getString("NamaSales"),
                              js.getString("Title"),
                              js.getString("Kota"),
                              js.getString("Harga"),
                              js.getString("IdProperty"));
                      itemlistjs.add(item);
                  }
              }catch (JSONException e) {
                  e.printStackTrace();
              }
          }
  
          @Override
          protected void onPostExecute(String result){
              if(result=="SUCCESS")
              {
              }else{              
                  JSONObject jObject = null;
                  Context mContext = null;
                  try {                   
                      jObject = new JSONObject(result);
                      JSONArray jArray = jObject.getJSONArray("listitem");
  
                      for (int i=0; i &lt; jArray.length(); i++)
                      {                     
                          JSONObject oneObject=jArray.getJSONObject(i);
                          ItemClass item=new ItemClass(oneObject.getString("IdProperty"),
                                  oneObject.getString("NamaSales"),
                                  oneObject.getString("Title"),
                                  oneObject.getString("Kota"),
                                  oneObject.getString("Harga"),
                                  oneObject.getString("IdProperty")); 
                          //Toast.makeText(getBaseContext(), oneObject.getString("Title"), Toast.LENGTH_SHORT).show();
                          //Log.d("helo",oneObject.getString("NamaSales"));
                          arritem.add(item);                          
                      }               
                      listview = (ListView) findViewById(R.id.listitem); 
                      Toast.makeText(getBaseContext(), arritem.get(0).toString(), Toast.LENGTH_SHORT).show();
                      listview.setAdapter(new ListViewAdapter(getBaseContext(), arritem));
                  }catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
              removeDialog(PROGRESS_DIALOG);
              super.onPostExecute(result);
          }       
      }   
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_saletab);
  
          connection = new ViewConnection(getBaseContext());
          if (connection.isConnectingToInternet())
          {
              BaseUrl="http://92.68.228.81/dummy/item.php?status=J";
              executeAsyncTask();             
          }else {
              // Internet connection is not present
              LayoutInflater li = LayoutInflater.from(Saletab.this);
              final View inputdialogcustom = li.inflate(R.layout.activity_confirm_connection, null);              
              AlertDialog.Builder alert = new AlertDialog.Builder(Saletab.this);                                              
              alert.setView(inputdialogcustom);       
  
              alert.setPositiveButton("OK", new DialogInterface.OnClickListener() { 
                  @Override
                  public void onClick(DialogInterface dialog, int which) {                                
                      System.exit(0);
                  }
              }); 
              alert.show();
          }       
      }
  
      private void executeAsyncTask(){
          Hashtable&lt;String,String&gt; ht=new Hashtable&lt;String,String&gt;();
          GetDeptAyncTask async=new GetDeptAyncTask();
          Hashtable[] ht_array={ht};
          async.execute(ht_array);
      }
  
  }
  </code></pre>
  
  <p>my layout :</p>
  
  <pre><code>&lt;RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical"&gt;
  
      &lt;!-- HEADER --&gt;
      &lt;LinearLayout
          android:id="@+id/header"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal" 
          android:layout_centerHorizontal="true"
          android:layout_alignParentTop="true"
          android:paddingTop="10dp"
          android:paddingBottom="10dp"
          android:background="#000"&gt;
          &lt;TextView
              android:id="@+id/tvlabel"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"          
              android:text="Jumlah data : "
              android:textColor="#FFF"&gt;           
          &lt;/TextView&gt;             
          &lt;View
              android:layout_width="fill_parent"
              android:layout_height="2dp"
              android:background="#acb0ac" /&gt;
      &lt;/LinearLayout&gt;
      &lt;!-- FOOTER --&gt;
      &lt;LinearLayout
          android:id="@+id/footer"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal" 
          android:layout_centerHorizontal="true"
          android:layout_alignParentBottom="true"
          android:paddingTop="10dp"
          android:paddingBottom="10dp"
          android:background="#000"&gt;
      &lt;/LinearLayout&gt;
  
      &lt;ListView
          android:id="@+id/listitem"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:padding="10dp"
          android:layout_above="@+id/header"
          android:layout_below="@+id/footer"&gt;
      &lt;/ListView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>my custom layout listview</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;    
      &lt;ImageView 
          android:id="@+id/imgitem" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content"
          android:background="@layout/round_border"
          android:src="@drawable/renticon"&gt; 
      &lt;/ImageView&gt; 
      &lt;TextView 
          android:id="@+id/title" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_marginTop="2dp" 
          android:text="Coba"
          android:textSize="13sp" &gt; 
      &lt;/TextView&gt; 
      &lt;TextView 
          android:id="@+id/harga" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:layout_marginTop="2dp" 
          android:text="Coba"
          android:textSize="13sp" &gt; 
      &lt;/TextView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Please help me ? Thank you.</p>