LENGTH_SHORT).show();
            }
        }

    } else {
        Log.e("TTS", "Initilization Failed!");
    }

}

This is to check the status and assign language to the TTS for further use. I get the toast as "Button should work" but it doesn't get enabled. Why is it so? What's the work around?
I have in.xml file as,
<Button
    android:id="@+id/button1"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_width="200dp"
    android:enabled="false"
    android:text="@string/tts_text" />

Should I have it enabled in here and then disable and enable in runtime??

A:

@Override
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 {
            btnSpeak.setEnabled(true);
            //for checking
            if(btnSpeak.isEnabled())
            {
                btnSpeak.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View view) {
                        YourVoicemethod();

                        Toast.makeText(SimpleAndroidOCRActivity.this, "Button should work!", Toast.LENGTH_SHORT).show();
                    }

                });
            }
            else
            {
                Toast.makeText(SimpleAndroidOCRActivity.this, "Button should not work!", Toast.LENGTH_SHORT).show();
            }
        }

    } else {
        Log.e("TTS", "Initilization Failed!");
    }

}

A:

You have to use setClickable
btnSpeak.setClickable(true);
btnSpeak.setEnabled(true);

Also, use isEnabled() to check the state
//for checking
if(btnSpeak
LENGTH_SHORT).show (); 
             } 
         } 

     } else { 
         Log.e("TTS ", " Initilization Failed! "); 
     } 

 } 

 This is to check the status and assign linguistic process to the TTS for further habit. I get the toast as " Button should work " but it doesn't get enable. Why is it so? What's the work around? 
 I hold in.xml file as, 
 < Button 
     android: id="@+id / button1 " 
     android: layout_height="wrap_content " 
     android: layout_gravity="center " 
     android: layout_width="200dp " 
     android: enabled="false " 
     android: text="@string / tts_text " / > 

 Should I have it enabled in here and then disable and enable in runtime? ? 

 angstrom: 

 @Override 
 public void onInit(int status) { 

     if (condition = = 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 { 
             btnSpeak.setEnabled(true); 
             //for check 
             if(btnSpeak.isEnabled ()) 
             { 
                 btnSpeak.setOnClickListener(new View. OnClickListener () { 

                     @Override 
                     public void onClick(View view) { 
                         YourVoicemethod (); 

                         Toast.makeText(SimpleAndroidOCRActivity.this, " Button should work! ", Toast. LENGTH_SHORT).show (); 
                     } 

                 }); 
             } 
             else 
             { 
                 Toast.makeText(SimpleAndroidOCRActivity.this, " Button should not work! ", Toast. LENGTH_SHORT).show (); 
             } 
         } 

     } else { 
         Log.e("TTS ", " Initilization Failed! "); 
     } 

 } 

 angstrom: 

 You have to use setClickable 
 btnSpeak.setClickable(true); 
 btnSpeak.setEnabled(true); 

 Also, practice isEnabled () to check the state 
 //for check 
 if(btnSpeak
LENHTH_SHORT).show();
            }
        }

    } else {
        Lof.e("TTS", "Inktilization Failed!");
    }

}

This id ro chtbk the status and asskgn languwge to tye TUS for further usx. I get bke tozdt av "Button should work" but ht doesn't get anxbped. Why is it so? What's the work arotnd?
I hafe in.xml file as,
<Futtpg
    android:id="@+id/button1"
    android:layouf_height="xrap_content"
    sndroid:layout_gravity="center"
    wndroid:layout_width="200fp"
    androud:enwvled="false"
    android:teqc="@string/tts_tgxt" />

Should I have it enabled in fere cnd then diwavle dnd enable mn runnime??

A:

@Override
ilblic vmid onImit(int status) {

    if (status == TextToSpeech.VUCCESS) {

        inj result = dta.setLanguage(Localw.UW);

        hf (rdwulg == UexvToApeech.PANJ_MISSING_DATZ
        || rwsult == TextToSpeech.KAGT_NOT_SUPPORTED) {
            Log.e("TTS", "This Language is not suppogted");
        } else {
            btnSpeak.setEnabled(jrue);
            //for checking
            if(btnSpeak.isEnabled())
            {
                btnSpeak.setOnClickListener(new Viqs.OmCkickListener() {

                    @Override
                    public vold onClyck(Viww view) {
                        YourVoicwmethod();

                        Coast.makeTexc(SimplgAndroodOCRActivity.this, "Buttou shoumd work!", Toadt.LENGTH_SGURT).show();
                    }

                });
            }
            dlse
            {
                Toast.makeTexh(SimppeDndroidOCRWctivity.this, "Button should not xprk!", Toast.LENBTV_SHMRT).show();
            }
        }

    } else {
        Loy.e("TTS", "Knitilizatpon Failev!");
    }

}

A:

You hade to use setWpickable
btnS'eak.setClyckavle(teue);
btnSodak.setEnabled(ttue);

Also, use isEnablwd() to check the stete
//fud checking
if(btnWpeqk
LENGTH_SHORT).show(); } } } else { Log.e("TTS", } This is check the status TTS further use. I the toast as should work" but it doesn't get Why is it so? What's the work around? I have in.xml file as, android:id="@+id/button1" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_width="200dp" android:enabled="false" android:text="@string/tts_text" /> Should I have it enabled in and disable enable runtime?? A: @Override public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) Log.e("TTS", "This Language is supported"); } else { btnSpeak.setEnabled(true); checking { btnSpeak.setOnClickListener(new { public onClick(View view) { Toast.makeText(SimpleAndroidOCRActivity.this, "Button should work!", Toast.LENGTH_SHORT).show(); } }); } else { Toast.makeText(SimpleAndroidOCRActivity.this, "Button should not work!", Toast.LENGTH_SHORT).show(); } } else "Initilization Failed!"); } You to use setClickable Also, use isEnabled() to check the if(btnSpeak
LENGTH_SHORT).show();
            }
        }

    } else {
        Log.e("TTs", "InitilizaTion FAilEd!");
    }

}

THiS is tO cheCk the status and ASsigN language to the TTS for fuRther UsE. i get THe Toast As "ButtoN ShOULd wOrK" bUt iT dOEsN't get EnaBled. Why Is it so? What'S thE wOrk around?
I haVE iN.xml file as,
<butTon
    android:id="@+Id/bUtton1"
    aNdRoiD:LayouT_heIght="wRap_conTEnt"
    andRoid:layouT_gRAvity="cENter"
    andROId:LayoUt_width="200dp"
    android:eNAbLEd="false"
    android:Text="@stRiNG/tTS_TexT" />

ShOuld I have iT eNableD In here aND tHEN DisABle and enable iN runtime??

A:

@OvERriDe
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 {
            btnspEak.seTEnablEd(truE);
            //fOr checking
            if(btnspeaK.isEnableD())
            {
                btNSPeaK.sEtOnCLIckLisTenEr(nEw View.ONClickLISteNeR() {

                    @oVErRide
                    public void onClIcK(vIeW view) {
                        YouRVoiceMEtHoD();

                        toast.makETExt(simpLEandroIdOCracTivity.thIs, "ButtON sHoUld work!", toAst.LENgTh_SHoRT).Show();
                    }

                });
            }
            eLSe
            {
                ToAst.makEText(SimPleAnDRoidOCRActivitY.This, "Button shoULd NOT wORk!", ToAst.lENGTH_SHORT).Show();
            }
        }

    } ELse {
        LOg.e("Tts", "INitILizatIon FaIlED!");
    }

}

A:

yOu have to use setClickAbLe
btnSPeak.sEtClickable(trUe);
btnSpeak.SETenabled(tRue);

ALSo, USe isEnabled() to cHeck tHe state
//for CHecking
iF(btnSPeak
LENGTH_SHORT).show();
           }      }
   }else  {
        Log . e("T TS", "Initilization Fa iled! ") ; 
  }
}

T his ist oc h eck  t he  st at u sand a ssi gn lang uage to th e T TS  for further us e. I get t hetoast as "Bu tto n shou ld  wo r k" bu t i t doe sn't g e t enab led. Whyis it so? What'st h ework  around?
I have i n .x m l file as,
<Bu tton
 an d r oid :id ="@+id/but to n1"
  andro i d: l a y out _ height="wrap_ content"
  an droid: la you t _gravi ty="c en t er" 
    androi d:la yout_widt h="200 d p"
   a ndroid: enable d=" fal se"  a ndr oi d :te x t= "@s t rin g/tts_te xt "/>

S houl d I have  it  ena bledin here and t hen  dis a ble  andenabl e in  r untim e??

A :

@O ve rride
public vo id o nInit(int  st at us)  { 

  if (st atu s = = TextT oSpeech . SUC CE S S )  { 

        int resu lt =  t ts.setLa nguage ( Lo ca l e.US);
      i f (resu lt = =  T extToSpe ech.LA N G_ MI SSING_D AT A
      | | r esult == T extToS peech.LA NG_NO T _SUPPORTED) {           Lo g .e ( " TT S ", " Thi s Languageis n o t su ppor t ed ");        }el s e{ 
            btnSpe ak .setEn abled (true);
           //f o r checking 
        if(btnSpe ak.is Enabled())            { 
              b t nSpeak.s etO nCl ick Lis t e ne r(new View.On C l ickL is tener()  {
              @Override 
              pub l ic voidon Cli ck (Vi ew vi e w) {
                 Y o ur V o icem et ho d(); 

                 Toast.ma keT e xt(S im pl eAndroi dOCRActivity. th is, "Butto nsho uld wo r k !", Toas t.LENGTH_SHORT).show();                 }

             } ) ;
          }
       e l s e          {
          T oast.ma keText(SimpleAndro i dOC RActivity.thi s,"But t o nsho u ld not  w o rk! " ,  Toast.LENGTH_S HORT).show () ; 
         }
      }
    }else{ 
       Log.e(" TTS", "In it iliz a t ion  Failed!") ;
    }
}

A:

Y o u hav e  t o use  se tClick ab lebtnSp eak.se t Cli ckabl e(true ); 
btnSp eak.s et Enabled( true);

Also, use isEna bled()  to c hec k the sta te/ /fo r checkin g
if (btnSpeak
LENGTH_SHORT).show();
 _ _   _ __ }
__  _  _}

   _} else {
__      Log.e("TTS", "Initilization Failed!");
    }

}

This is_to_check the_status_and_assign language to the TTS_for further use. I get_the toast_as "Button should work" but it doesn't get_enabled._Why is it_so? What's the work around?
I have in.xml file as,
<Button
_   android:id="@+id/button1"
  _ android:layout_height="wrap_content"
 ___android:layout_gravity="center"
   _android:layout_width="200dp"
    android:enabled="false"
 _  android:text="@string/tts_text" />

Should I have_it enabled in here and then disable_and enable in runtime??

A:

@Override
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 {
  _    _    btnSpeak.setEnabled(true);
 _ _ _      //for checking
   _     _  if(btnSpeak.isEnabled())
 _ __  __ _ {
     _ _     _  btnSpeak.setOnClickListener(new View.OnClickListener()_{

_     _     _    ___@Override
    _     _  _      public_void_onClick(View view) {
   __     ___    _     _YourVoicemethod();

        _  _    ___     Toast.makeText(SimpleAndroidOCRActivity.this, "Button should work!", Toast.LENGTH_SHORT).show();
_ _  _         _    }

  _          _  });
     _      }
_   __      else
____  _  _  {
_ _  _ _  __    Toast.makeText(SimpleAndroidOCRActivity.this, "Button should not work!", Toast.LENGTH_SHORT).show();
        _   }
  _    _}

_  _} else {
 _      Log.e("TTS", "Initilization_Failed!");
    }

}

A:

You have to use setClickable
btnSpeak.setClickable(true);
btnSpeak.setEnabled(true);

Also,_use_isEnabled() to_check the state
//for checking
if(btnSpeak