Android provides a special feature for checking spelling and it is easy to implement in your App.
Android provides SpellCheckerSessionListener listener that handles spelling checker.
For spelling checker, we have to implement SpellCheckerSessionListener listener that have some
methods that we need to use.
In order to use spelling checker, you need to implement SpellCheckerSessionListener interface and
override its methods.
Here is the way to implement
public class CheckSpellingActivity extends Activity implements SpellCheckerSessionListener {
@Override
public void onGetSuggestions(finalSuggestionsInfo[] arg0)
{
// TODO Auto-generated method stub
}
@Override
Public void onGetSentenceSuggestions(SentenceSuggestionsInfo[] arg0){
// TODO Auto-generated method stub
}}
Then we need to use SpellcheckerSession class.
private SpellCheckerSession spellCheckerSession;
final TextServicesManager textServicesManager =(TextServicesManager)
getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE);
spellCheckerSession = textServicesManager.newSpellCheckerSession(null,null,this,true);
Now we have to call getSuggestions() for suggestion and this takes you to onGetSuggestions() where you
can handle it.
spellCheckerSession.getSuggestions(newTextInfo(nameEditText.getText().toString()),2);
0 Comment(s)