How to add Text to speech on retrieved Listview from sqlite in android java -


i retrieved data sqlite , need add tts (text speech) on each retrieved row not work when prees on listview read listview items retrieved in sqlite, please me.

my java activity :

 public class favorites extends activity implements adapterview.onitemclicklistener, texttospeech.oninitlistener { listview lv; private  texttospeech tts; private sqlitedatabase db; cursor mcursor; simplecursoradapter madapter;  databasehelper mhelper; @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.favorite);     tts = new texttospeech(this, this);     tts.setlanguage(locale.english);     tts.setpitch(0.8f);     tts.setspeechrate(1.5f);     lv = (listview) findviewbyid(r.id.list);     lv.setonitemclicklistener(this);      mhelper = new databasehelper(this); } @override public void onresume() {     super.onresume();     db = mhelper.getwritabledatabase();     final string[] columns = new string[] {"_id", databasehelper.key_favorite, databasehelper.key_pronounciation, databasehelper.key_created_at};     mcursor = db.query(databasehelper.table_name, columns, null, null, null, null, null, null);     string[] headers = new string[] {databasehelper.key_favorite, databasehelper.key_pronounciation, databasehelper.key_created_at};     madapter = new simplecursoradapter(this, android.r.layout.two_line_list_item,mcursor, headers, new int[]{android.r.id.text1, android.r.id.text2}  );      lv.setadapter(madapter);  }  @override public void onpause() {     super.onpause();     db.close();     mcursor.close(); }   @override public void onitemclick(adapterview<?> parent, view view, int position, long id) {  }   @override public void oninit(int status) {      // todo auto-generated method stub     // check see if text speech suppourted on device     if (status == texttospeech.success) {         toast.maketext(favorites.this,                 "engine ready", toast.length_short).show();     }      //if text speech not supported output error message     else if (status == texttospeech.error) {         toast.maketext(favorites.this,                 "error occurred while initializing text-to-speech engine dont have installed", toast.length_long).show();     } } 

}


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -