Note that there are some explanatory texts on larger screens.

plurals
  1. POText to speech not working while using that one in listitem click and myactivity is in Tabactivity
    primarykey
    data
    text
    <p>I have an dynamic listview ,while clicking the list item,that string array has been converted into text to speech function,i store that string array in an string and then only i convert into text to speech.</p> <p>Here i included my code..</p> <pre><code>public class TTSList extends ListActivity implements TextToSpeech.OnInitListener { private static final int ACTIVITY_CREATE=0; private static final int ACTIVITY_EDIT=1; private GinfyDbAdapter mDbHelper; private SimpleCursorAdapter dataAdapter; ListView lv; public Button btnadd1; private TextToSpeech tts; String typed1; public String praystring; public TextView txtText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tts_list); lv =(ListView)findViewById(R.id.list); mDbHelper = new GinfyDbAdapter(this); btnadd1 = (Button)findViewById(R.id.btnadd); btnadd1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { createProject(); } }); mDbHelper.open(); fillData(); registerForContextMenu(getListView()); } @SuppressLint("NewApi") @SuppressWarnings("deprecation") private void fillData() { mDbHelper.open(); Cursor projectsCursor = mDbHelper.fetchAllProjects1(); //startManagingCursor(projectsCursor); // Create an array to specify the fields we want to display in the list (only TITLE) String[] from = new String[]{GinfyDbAdapter.CATEGORY_COLUMN_PRAYERNAME,GinfyDbAdapter.CATEGORY_COLUMN_WDATE}; // and an array of the fields we want to bind those fields to (in this case just text1) int[] to = new int[]{R.id.text1,R.id.date}; dataAdapter = new SimpleCursorAdapter( this, R.layout.activity_row2, projectsCursor, from, to, 0); setListAdapter(dataAdapter); EditText myFilter = (EditText) findViewById(R.id.myFilter); myFilter.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { dataAdapter.getFilter().filter(s.toString()); } }); dataAdapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { return mDbHelper.fetchProjectByName(constraint.toString()); } }); tts = new TextToSpeech(this, this); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. super.onCreateOptionsMenu(menu); MenuInflater mi = getMenuInflater(); mi.inflate(R.menu.activity_main, menu); return true; } @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { switch(item.getItemId()) { case R.id.menu_insert: createProject(); return true; } return super.onMenuItemSelected(featureId, item); } @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater mi = getMenuInflater(); mi.inflate(R.menu.activity_menu_long, menu); } @Override public boolean onContextItemSelected(MenuItem item) { switch(item.getItemId()) { case R.id.menu_delete: AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); mDbHelper.deleteProject1(info.id); fillData(); return true; case R.id.menu_edit: AdapterContextMenuInfo info1 = (AdapterContextMenuInfo) item.getMenuInfo(); Intent i = new Intent(this, TTSprayer.class); i.putExtra(GinfyDbAdapter.CATEGORY_COLUMN_ID1, info1.id); startActivityForResult(i, ACTIVITY_EDIT); return true; } return super.onContextItemSelected(item); } private void createProject() { Intent i = new Intent(this, TTSprayer.class); startActivityForResult(i, ACTIVITY_CREATE); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); Cursor Release = mDbHelper.fetchProject1(id); String Releasename = Release.getString(Release.getColumnIndexOrThrow(GinfyDbAdapter.CATEGORY_COLUMN_GODNAME)); String Releasename1 = Release.getString(Release.getColumnIndexOrThrow(GinfyDbAdapter.CATEGORY_COLUMN_PRAYFOR)); String Releasename2 = Release.getString(Release.getColumnIndexOrThrow(GinfyDbAdapter.CATEGORY_COLUMN_PRAYEEENAME)); List&lt;String&gt; godname = new ArrayList&lt;String&gt;(Arrays.asList(Releasename.split(","))); List&lt;String&gt; prayfor = new ArrayList&lt;String&gt;(Arrays.asList(Releasename1.split(","))); List&lt;String&gt; people = new ArrayList&lt;String&gt;(Arrays.asList(Releasename2.split(","))); for (String temp : godname) { for (String temp1 : prayfor) { for (String temp2 : people) { praystring = temp +" " + temp1 +" "+ temp2 + " "; } } } typed1 = praystring; speakOut(); } @Override public void onDestroy() { // Don't forget to shutdown tts! if (tts != null) { tts.stop(); tts.shutdown(); } super.onDestroy(); } public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = tts.setLanguage(Locale.US); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e("TTS", "This Language is not supported"); } else { //btnaudioprayer.setEnabled(true); speakOut(); } } else { Log.e("TTS", "Initilization Failed!"); } } private void speakOut() { tts.speak(typed1, TextToSpeech.QUEUE_FLUSH, null); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); fillData(); } </code></pre> <p>while clicking the row in an list,it has to produce the text to speech conversion,But rite now i didn't get any conversion.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload