title: Android listview refresh with blink
body: <p>i have a <code>listview</code> data come from server its working fine bu when <code>listview</code> refresh its blink how to made it <code>listview</code> did not blink.
  here is my code of <code>listview</code>. i used handler for refresh <code>listview</code>.</p>
  
  <pre><code>list = (ListView) findViewById(R.id.listView);
      personList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
      adapter = new SimpleAdapter(
              DataSendActivity.this, personList, R.layout.layout_chat,
              new String[]{TAG_DATA, TAG_CREATED_AT},
              new int[]{R.id.data, R.id.created}
      );
      list.setAdapter(adapter);
  
     final Handler handler = new Handler();
      handler.postDelayed( new Runnable() {
  
          @Override
          public void run() {
              //showList();
              isInternetPresent = cd.isConnectingToInternet();
              if (isInternetPresent) {
                  personList.clear();
                  try{
                      getData();
                  }catch (Exception e){}
  
                  adapter.notifyDataSetChanged();
                  list.invalidateViews();
              } else {
                  showAlertDialog(DataSendActivity.this, "No Internet Connection",
                          "You don't have internet connection.", false);
              }
  
              //list.refreshDrawableState();
              handler.postDelayed( this, 8000 );
          }
      }, 8000 );
  </code></pre>
  
  <p>here is the function which show data.</p>
  
  <pre><code>    protected void showList() {
          try {
              JSONObject jsonObj = new JSONObject(myJSON);
              peoples = jsonObj.getJSONArray(TAG_RESULTS);
  
              for (int i = 0; i &lt; peoples.length(); i++) {
                  JSONObject c = peoples.getJSONObject(i);
                  String data = c.getString(TAG_DATA);
                  String created_at = c.getString(TAG_CREATED_AT);
  // final String dataaaa = rcdata.getText().toString().trim();
                  HashMap&lt;String, String&gt; user_data = new HashMap&lt;String, String&gt;();
                  user_data.put(TAG_DATA, data);
                  user_data.put(TAG_CREATED_AT, created_at);
  
  
                  personList.add(user_data);
  
              }
              try{
                  adapter.notifyDataSetChanged();
              }catch (Exception e){
  
              }
  
          } catch (JSONException e) {
              e.printStackTrace();
          }
  
      }
  </code></pre>
  
  <p>this is getdata code.</p>
  
  <pre><code>public void getData() {
      class GetDataJSON extends AsyncTask&lt;String, Void, String&gt; {
          //String recID = ;
          //String userID = email;
          @Override
          protected String doInBackground(String... params) {
              DefaultHttpClient httpclient = new DefaultHttpClient(new BasicHttpParams());
              HashMap&lt;String, String&gt; user = db.getUserDetails();
  
              //String name = user.get("name");
             // Semail = user.get("email");
  
              String semail  = user.get("email");
              final String remail = rremail;
  
              HttpPost httppost = new HttpPost("http://samplechatapp.gear.host/myphpfile.php?sender_email="+semail+"&amp;reciver_email="+remail+"&amp;fatch_server_data=true");
  
              // Depends on your web service
              httppost.setHeader("Content-type", "application/json");
  
              InputStream inputStream = null;
              String result = null;
              Log.i("","processing entity");
              try {
                  HttpResponse response = httpclient.execute(httppost);
                  HttpEntity entity = response.getEntity();
  
                  inputStream = entity.getContent();
                  // json is UTF-8 by default
                  BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 8);
                  StringBuilder sb = new StringBuilder();
  
                  String line = null;
                  while ((line = reader.readLine()) != null) {
                      sb.append(line + "\n");
                      Log.i("",line);
                  }
                  result = sb.toString();
                  Log.i("",result);
              } catch (Exception e) {
                  // Oops
              } finally {
                  try {
                      if (inputStream != null) inputStream.close();
                  } catch (Exception squish) {
                  }
              }
              return result;
          }
  
          @Override
          protected void onPostExecute(String result) {
              myJSON = result;
              showList();
          }
      }
      GetDataJSON g = new GetDataJSON();
      g.execute();
  }
  </code></pre>
  
  <p>listview working fine but problem is this when listview refresh its blink i want listview refresh without blinking. thanks in advance</p>