简体   繁体   中英

Spell checker in android

I want to create an application in which it checks if the word typed by user is correct or not using Google Dictionary ? i have used the below link . But the problem with the given example is that it suggests the different words. I don't want suggestion, instead i want to only check that word entered is correct or not.

I haven't worked on it yet. But you can probably modify it as:

When you get the suggestions, instead of appending them to StringBuilder, and showing that StringBuilder to MainView, just compare all suggestions with your input string of edittext.

If it matches, then the spell is correct, else the spell is incorrect.

Code snippet:

@Override
public void onGetSuggestions(final SuggestionsInfo[] arg0) {
    isSpellCorrect = false;
    final StringBuilder sb = new StringBuilder();
    for (int i = 0; i < arg0.length; ++i) {
        // Returned suggestions are contained in SuggestionsInfo
        final int len = arg0[i].getSuggestionsCount();
        if(editText1.getText().toString().equalsIgnoreCase(arg0[i].getSuggestionAt(j))
        {
            isSpellCorrect = true;
            break;
        }               
     }        
 }

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM