I have build a simple android app. In my activity most of the buttons work but others don't -
this code given below java code 1 of activity. activity have used button. problem buttons condition t works fine after them u z doesn't work although code same buttons. needs help.
package irtiza.alphabets; import android.app.activity; import android.content.context; import android.content.intent; import android.media.audiomanager; import android.speech.tts.texttospeech; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.imageview; import java.util.locale; import java.util.random; public class alphabet_meaning extends activity implements view.onclicklistener { // voices string alphabet_meaning_voices = null; texttospeech tts; ///// @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_alphabet_meaning); // text voice button voice1 = (button) findviewbyid(r.id.b_1); voice1.setonclicklistener(alphabet_meaning.this); // // getting values intent intent_get = getintent(); bundle b = intent_get.getextras(); //// string image_button_values = (string) b.get("ib"); tts = new texttospeech(alphabet_meaning.this, new texttospeech.oninitlistener() { @override public void oninit(int status) { if (status != texttospeech.error) { tts.setlanguage(locale.us); } } }); ////////// if ( image_button_values.matches("a") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.apple); alphabet_meaning_voices="a apple"; } /// b else if ( image_button_values.matches("b") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.ball); alphabet_meaning_voices="b ball"; } /// c else if ( image_button_values.matches("c") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.car); alphabet_meaning_voices="c car"; } /// d else if ( image_button_values.matches("d") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.dolphen); alphabet_meaning_voices="d dolphen"; } /// e else if ( image_button_values.matches("e") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.elephant); alphabet_meaning_voices="e elephant"; } /// f else if ( image_button_values.matches("f") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.flower); alphabet_meaning_voices="f flower"; } /// g else if ( image_button_values.matches("g") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.giraffe); alphabet_meaning_voices="g giraffe"; } /// h else if ( image_button_values.matches("h") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.house); alphabet_meaning_voices="h house"; } /// else if ( image_button_values.matches("i") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.ice_cream); alphabet_meaning_voices="i ice cream"; } /// j else if ( image_button_values.matches("j") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.jeep); alphabet_meaning_voices="j jeep"; } /// k else if ( image_button_values.matches("k") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.kite); alphabet_meaning_voices="k kite"; } /// l else if ( image_button_values.matches("l") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.lion); alphabet_meaning_voices="l lion"; } /// menter code here else if ( image_button_values.matches("m") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.moon); alphabet_meaning_voices="m moon"; } /// n else if ( image_button_values.matches("n") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.net); alphabet_meaning_voices="n net"; } /// o else if ( image_button_values.matches("o") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.orange); alphabet_meaning_voices="o orange"; } /// p else if ( image_button_values.matches("p") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.parrot); alphabet_meaning_voices="p parrot"; } /// q else if ( image_button_values.matches("q") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.quail); alphabet_meaning_voices="q quail"; } /// r else if ( image_button_values.matches("r") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.rabbit); alphabet_meaning_voices="r rabbit"; } /// s else if ( image_button_values.matches("s") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.shoe); alphabet_meaning_voices="s shoe"; } /// t else if ( image_button_values.matches("t") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.tomato); alphabet_meaning_voices="t tomato"; } /// u else if ( image_button_values.matches("u") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.umbrella); alphabet_meaning_voices="u umbrella"; } /// v else if ( image_button_values.matches("v") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.voilin); alphabet_meaning_voices="v violin"; } /// w else if ( image_button_values.matches("w") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.watch); alphabet_meaning_voices="w watch"; } /// x else if ( image_button_values.matches("x") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.xylophone); alphabet_meaning_voices="x xylophone"; } /// y else if ( image_button_values.matches("y") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.yak); alphabet_meaning_voices="y yak"; } /// z else if ( image_button_values.matches("z") ) { imageview img= (imageview) findviewbyid(r.id.iv1); img.setimageresource(r.drawable.zebra); alphabet_meaning_voices="z zebra"; } /////////////////////////////////////////////////// } // protected void onpause () { // if ( tts != null) { // tts.stop(); // tts.shutdown(); // } // // super.onpause(); // } @override public void onclick(view v) { random r = new random(); string random = alphabet_meaning_voices; tts.setspeechrate((float) 0.5); audiomanager = (audiomanager)getsystemservice(context.audio_service); int amstreammusicmaxvol = am.getstreammaxvolume(am.stream_music); am.setstreamvolume(am.stream_music, amstreammusicmaxvol, 0); tts.speak(random, texttospeech.queue_flush, null); } }
i used android intent pass specific value of button activity. issue in code button , using wrong key value passing in activity.:
imagebutton ib_s = (imagebutton) findviewbyid(r.id.ib_s); ib_s.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { //startactivity( new intent( alphabat_pics.this, alphabet_meaning.class )); alphabet_meaning.putextra("ib", string_array[18]); startactivity(alphabet_meaning); } });
Comments
Post a Comment