title: How to set the textview if condition is satisfied?
body: <p>Here in my previous question <a href="https://stackoverflow.com/questions/27062720/how-to-print-message-when-json-response-has-no-fileds/27074203?noredirect=1#comment42660200_27074203">How to Print Message when Json Response has no fileds?</a> Toast is working fine but if my response is showing no fileds with array and what if I want to use textview instead of Toast? can anyone help me?<img src="https://i.stack.imgur.com/ivf69.png" alt="enter image description here"></p>
  
  <pre><code>public class MessageSent extends ListActivity{
  
      private ProgressDialog pDialog;
      JSONArray msg=null;
      private TextView nomsg;
  
      private ListView listview;
  
      private ArrayList&lt;HashMap&lt;String,String&gt;&gt; aList;
      private static String MESSAGE_URL = "";
      private static final String MESSAGE_ALL="msg";
      private static final String MESSAGEUSER_ID="msg_user_id";
      private static final String MESSAGE_NAME="name";
      private static final String MESSAGE_PROFILE="profile_id";
      private static final String MESSAGE_IMAGE="image";
      private static final String MESSAGE_CAST="cast";
      private static final String MESSAGE_AGE="age";
      private static final String MESSAGE_LOCATION="location";
      private CustomAdapterMessage adapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.list_view_msgsent);
          nomsg=(TextView)findViewById(R.id.no_message);
          String strtexts = getIntent().getStringExtra("id");
          System.out.println("&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; id : " + strtexts);
          MESSAGE_URL = "xxxxx"+strtexts;
  
          // listview=(ListView)findViewById(R.id.list);
  
          //ListView listview = this.getListView();
  
          ListView listview = (ListView)findViewById(android.R.id.list);
  
          new LoadAlbums().execute();
  
  
              }
          });
      }
  
      class LoadAlbums extends AsyncTask&gt;&gt; {
  
          /**
           * Before starting background thread Show Progress Dialog
           * */
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              pDialog = new ProgressDialog(MessageSent.this);
              pDialog.setMessage("Loading...");
              pDialog.setIndeterminate(false);
              pDialog.setCancelable(false);
              pDialog.show();
          }
  
          protected ArrayList&lt;HashMap&lt;String,String&gt;&gt; doInBackground(String... args) {
              ServiceHandler sh = new ServiceHandler();
  
              // Making a request to url and getting response
              ArrayList&lt;HashMap&lt;String,String&gt;&gt; data = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
              String jsonStr = sh.makeServiceCall(MESSAGE_URL, ServiceHandler.GET);
  
              Log.d("Response: ", "&gt; " + jsonStr);
  
              if (jsonStr != null) 
              {
                  try 
                  {
                      JSONObject jsonObj = new JSONObject(jsonStr);
  
                      // Getting JSON Array node
                      msg = jsonObj.getJSONArray(MESSAGE_ALL);
  
                      // looping through All Contacts
                      for (int i = 0; i &lt; msg.length(); i++) 
                      {
                          JSONObject c = msg.getJSONObject(i);
  
                          // creating new HashMap
                          HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
                          // adding each child node to HashMap key =&gt; value
                          map.put(MESSAGEUSER_ID ,c.getString(MESSAGEUSER_ID));
                          map.put(MESSAGE_NAME,c.getString(MESSAGE_NAME));
                          map.put(MESSAGE_PROFILE, c.getString(MESSAGE_PROFILE));
                          map.put(MESSAGE_IMAGE, c.getString(MESSAGE_IMAGE));
                          map.put(MESSAGE_CAST, c.getString(MESSAGE_CAST));
                          map.put(MESSAGE_AGE, c.getString(MESSAGE_AGE)+" years");
                          map.put(MESSAGE_LOCATION, c.getString(MESSAGE_LOCATION));
  
                          // adding HashList to ArrayList
                          data.add(map);
                      }
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              } else {
                  Log.e("ServiceHandler", "Couldn't get any data from the url");
              }
  
              return data;
          }
  
          protected void onPostExecute(ArrayList&lt;HashMap&lt;String,String&gt;&gt; result) {
              super.onPostExecute(result);
  
              // dismiss the dialog after getting all albums
              if (pDialog.isShowing())
                  pDialog.dismiss();
  
              if(msg == null || msg.length() == 0) { 
                  //Toast.makeText(getApplicationContext(), "No response", Toast.LENGTH_LONG).show
                  nomsg.setText("No Message Found");
                  //nomsg.setBackgroundDrawable(R.drawable.borders);
              }
  
              if(aList == null) {
                  aList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
                  aList.addAll(result);
                  adapter = new CustomAdapterMessage(getBaseContext(), result);
                  setListAdapter(adapter);
              } else {
                  aList.addAll(result);
                  adapter.notifyDataSetChanged();
              }
          }
  
      }
  }
  </code></pre>