2017-08-02 31 views
0

首先,感謝大家的光臨並對不起我的英文不好,所以我形容這種局面直接,(安卓)如何清除在某些情況下鍵盤內存(宏基鍵盤)

我與索尼開發,當我點擊EditText中的清除按鈕時,它正常工作!,即使我使用其他手機,如HTC,Oppo,mi ..一切都好!

之後,我試圖在宏基安裝它,清除按鈕仍在工作,

但!!!!!

當我點擊清除按鈕後,再次使用鍵盤,我的第一個輸入的數據還在這裏。

The data of my first input.

所以,「MyFirstData」仍將因爲我不知道如何解決它出現的時候,我再次輸入像

Second-time input situation

我真的很困惑。

那麼我能做些什麼,清除鍵盤數據?怎麼樣?

非常感謝!!!!




代碼在這裏:
binding.searchView是我editext

binding.searchView.addTextChangedListener(new TextWatcherAdapter()); 
    binding.searchView.setOnEditorActionListener(getSearchEditListener()); 
    channelDialogHelper = new ChannelDialogHelper(this); 
} 

private TextView.OnEditorActionListener getSearchEditListener() { 
    return new TextView.OnEditorActionListener() { 
     @Override 
     public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { 
      if (actionId == EditorInfo.IME_ACTION_SEARCH) { 
       messageResultAdapter.clearAdapter(); 
       shareFileResultAdapter.clearAdapter(); 
       keyword = MessageFactory.getInstance().parseSourceData(v.getText().toString()); 
       if (StringUtil.isEmpty(keyword)) { 
        return false; 
       } 

       hasMessageResult = false; 
       hasFileResult = false; 

       if (binding.searchMessageButton.isSelected()) { 
        searchMessageListener(binding.searchMessageButton); 

       } else if (binding.searchFileButton.isSelected()) { 
        searchFileListener(binding.searchFileButton); 
       } 
       return true; 
      } 
      return false; 
     } 
    }; 
} 



TextWatcherAd更易:

public class TextWatcherAdapter implements TextWatcher { 
public TextWatcherAdapter() { 
} 

public void beforeTextChanged(CharSequence var1, int var2, int var3, int var4) { 
} 

public void onTextChanged(CharSequence var1, int var2, int var3, int var4) { 
} 

public void afterTextChanged(Editable var1) { 
} 

}

+0

你在開玩笑嗎?你的代碼在哪裏? – UmarZaii

+0

我現在正在編輯,給我第二個 –

+0

我遇到了同樣的問題.. –

回答

0

一種可能的解決辦法是刪除使用ContentResolver.delete確切字(一個或多個)()。例如:

private int deleteWord(String word) { 
if (TextUtils.isEmpty(word)) { 
    return -1; 
} 
return getContentResolver().delete(UserDictionary.Words.CONTENT_URI, 
     UserDictionary.Words.WORD + "=?", new String[] { word }); 
} 

當然而且,需要

<uses-permission android:name="android.permission.WRITE_USER_DICTIONARY" /> 

在清單中所定義。

希望這會有所幫助。

+0

但下次輸入,它仍然在這裏,就像鍵盤內存或類似的東西 –

+0

嘗試這一個:它通過在xml中添加以下行禁用軟鍵盤上的建議 - android:inputType =「textNoSuggestions」 – karthik

+0

它是不工作,我只想第二次沒有建議 –