edtScan.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
String scanertext = edtScan.getText().toString();
if (scanertext.contains("-") && scanertext.length() > 3) {
edtScan.setText("");
RefreshWebView(scanertext);
} else if (scanertext.length() > 0) {
edtScan.setText("");
String msg = "編碼規則不符,請掃描位置二維碼!";
Toast.makeText(HtmlViewActivity.this, msg,
Toast.LENGTH_SHORT).show();
MainActivity.getInstance().SpeakVoice(msg);
String head = "<head>"
+ "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\"> "
+ "<style>html{padding:15px;} body{word-wrap:break-word;font-size:13px;padding:0px;margin:0px} p{padding:0px;margin:0px;font-size:13px;color:#222222;line-height:1.3;} img{padding:0px,margin:0px;max-width:100%; width:auto; height:auto;}</style>"
+ "</head>";
webview.loadData("<html>" + head + "<body>"
+ " <h1>請掃描位置二維碼!eg:A-R1:C1</h1> " + "</body></html>",
"text/html;charset=utf-8", "utf-8");
}
return true;
}
});
}