title: How to make the TTS to read all the Listview items by clicking it only once?
body: <p>I have a Listview in android that can be read by TTS when you click the items it reads it, but my problem is how to make the TTS to read all the items by clicking any of the items in the listview only once? </p>
  
  <p>here's the codes</p>
  
  <pre><code> package learn2crack.listview;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Locale;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import android.app.Activity;
  import android.app.ProgressDialog;
  import android.content.Intent;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.speech.tts.TextToSpeech;
  import android.speech.tts.TextToSpeech.OnInitListener;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.Button;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  import android.widget.TextView;
  import android.widget.Toast;
  
  
  
  import learn2crack.listview.library.JSONParser;
  
  
  
  public class MainActivity extends Activity implements TextToSpeech.OnInitListener {
  ListView list;
  TextView html;
  Button Btngetdata;
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; oslist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
  //URL to get JSON Array
  private static String url = "http://maps.googleapis.com/maps/api/directions/json?origin=Chicago,IL&amp;destination=New%20York,NY&amp;sensor=false"; //url is just a sample
  
  //JSON Node Names 
  private static final String TAG_OS = "routes";
  private static final String TAG_HTM = "html_instructions";
  private TextToSpeech myTTS;
  private int MY_DATA_CHECK_CODE = 0;
  
  JSONArray android = null;
  
   public void onInit(int initStatus) {
  
          // check for successful instantiation
          if (initStatus == TextToSpeech.SUCCESS) {
              if (myTTS.isLanguageAvailable(Locale.US) == TextToSpeech.LANG_AVAILABLE)
                  myTTS.setLanguage(Locale.US);
          } else if (initStatus == TextToSpeech.ERROR) {
              Toast.makeText(this, "Sorry! Text To Speech failed...",
                      Toast.LENGTH_LONG).show();
          }
      }
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_main);
      oslist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
  
  
      Btngetdata = (Button)findViewById(R.id.getdata);
      Btngetdata.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View view) {
               new JSONParse().execute();
  
  
          }
      });
  
  
  }
  
  
  private class JSONParse extends AsyncTask&lt;String, String, JSONObject&gt; {
       private ProgressDialog pDialog;
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
           html = (TextView) findViewById(R.id.html_instruction);
          pDialog = new ProgressDialog(MainActivity.this);
          pDialog.setMessage("Getting Data ...");
          pDialog.setIndeterminate(false);
          pDialog.setCancelable(true);
          pDialog.show();
  
  
  
      }
  
      @Override
      protected JSONObject doInBackground(String... args) {
  
          JSONParser jParser = new JSONParser();
  
          // Getting JSON from URL
          JSONObject json = jParser.getJSONFromUrl(url);
          return json;
      }
       @Override
       protected void onPostExecute(JSONObject json) {
           pDialog.dismiss();
           try {
                  // Getting JSON Array from URL
                  android = json.getJSONArray(TAG_OS);
                  for (int x = 0; x &lt; android.length(); x++) {
                      JSONArray legs = android.getJSONObject(x).getJSONArray("legs");
                      JSONObject distance = legs.getJSONObject(0).getJSONObject("distance");
                      JSONObject duration = legs.getJSONObject(0).getJSONObject("duration");
                      JSONArray steps = legs.getJSONObject(0).getJSONArray("steps");
  
                      for (int j = 0; j &lt; steps.length(); j++) {
                              String html_instructions = steps.getJSONObject(j).getString("html_instructions");
                              String s = html_instructions.replaceAll("&lt;(\"[^\"]*\"|'[^']*'|[^'\"&gt;])*&gt;", " ");
  
  
  
  
                  //for(int i = 0; i &lt; android.length(); i++){
                  //JSONObject c = android.getJSONObject(i);
  
                  // Storing  JSON item in a Variable
                  //String ver = c.getString(TAG_VER);
                  //String name = c.getString(TAG_NAME);
                  //String api = c.getString(TAG_API);
                  //String htm = c.getString("html_instructions");
  
  
  
                  // Adding value HashMap key =&gt; value
  
  
                  HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
  
  
                  map.put(TAG_HTM, s);
  
                  oslist.add(map);
                  list=(ListView)findViewById(R.id.list);
  
  
  
  
  
                  final ListAdapter adapter = new SimpleAdapter(MainActivity.this, oslist,
                          R.layout.list_v,
                          new String[] {TAG_HTM}, new int [] {R.id.html_instruction});
  
                  list.setAdapter(adapter);
                  Intent checkTTSIntent = new Intent();
                  checkTTSIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
                  startActivityForResult(checkTTSIntent, MY_DATA_CHECK_CODE);
                  list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
  
  
                      public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                                              int position, long id) {
                          //Toast.makeText(MainActivity.this, "You Clicked at "+oslist.get(+position).get("html"), Toast.LENGTH_SHORT).show();
                          parent.getAdapter();
                          //adapter.getItem(position).toString();
                          String words = adapter.getItem(position).toString();
                         //  String words = html.getText().toString();
                          speakWords(words);
  
                      }
                      private void speakWords(String speech) {
                          //speak straight away
                          myTTS.speak(speech, TextToSpeech.QUEUE_FLUSH, null);
                  }
  
                  });
  
  
                  }
          }} catch (JSONException e) {
              e.printStackTrace();
          }
  
  
  
       }
  }
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (requestCode == MY_DATA_CHECK_CODE) {
          if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
              //the user has the necessary data - create the TTS
          myTTS = new TextToSpeech(this,(OnInitListener) this);
          }
          else {
                  //no data - install it now
              Intent installTTSIntent = new Intent();
              installTTSIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
              startActivity(installTTSIntent);
          }
      }
  }
  </code></pre>
  
  <p>}</p>