I'm new in android studio. I'm working on a simple project. It uses a webview which loads the html page. I also use an action bar for searching, refreshing , ... in the page bellow:
By pressing the search button, findAllAsync() method is used to find and highlight all the matches in the page (matches are shown in yellow color). The next button in the action bar uses the findnext(true) method and allows user to move between the highlighted matches. Using this method, the next one is highlighted in red color:
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
st = et.getText().toString();
if(!st.equals("")&& st!=null) {
ourBrow.findNext(true);
}//not null
}//on click
});// next Button click
If I only scroll or zoom in the webview everything is ok and the find next is continued from the previous one in the page. However if i touch somewhere in the webview and then click the next button, the red highlighting is not continued from the previous position in the page. For example if the previous red highlighted is at the first of the page and i touch the end of the page and when i click the next button, the middle yellow matches are escaped and the last one which is in end of the page is highlighted in red color and red highlighting is continued from this position.
Since i need the user can continue search from the previous position and touching the screen does not affect this order, i searched a lot. I tried to disable touch event of the webview but keeping zoom and scroll ability based on the Android disable WebView touch but keep zooming/scrolling. But my problem is still unsolved. Please kindly help me to solve this problem.
thanks.
Edit:
To solve this problem i tried to clear focus of the view(How to remove focus without setting focus to another control?). But it doesn't work:
View current = getCurrentFocus();
if (current != null) current.clearFocus();
ourBrow.findNext(true);