我在我的應用中使用Web視圖並加載了「http://google.com」 網址,現在我想自動搜索我在TextView中輸入的單詞。在Android中使用Web視圖HTML
日Thnx回答我只是用這個和它的作品
String qString ="http://www.google.com/search?q=%s";
String test="dogs";
String q = qString + test;
web.loadUrl(q);
一個非常簡單的方法。嘆
我在我的應用中使用Web視圖並加載了「http://google.com」 網址,現在我想自動搜索我在TextView中輸入的單詞。在Android中使用Web視圖HTML
日Thnx回答我只是用這個和它的作品
String qString ="http://www.google.com/search?q=%s";
String test="dogs";
String q = qString + test;
web.loadUrl(q);
一個非常簡單的方法。嘆
使用String.format(..)方法將參數放置在字符串中。所以
String qString ="http://www.google.com/search?q=%s";
是查詢字符串。
String test="dogs"; // or whatever.
String.format(qString, test);
so webview.loadurl =「?」; – User 2012-07-27 03:50:56
嗯,我認爲「http://www.google.com/search?q=%s」將值應用於qString後。 – 2012-07-27 22:05:24
我可以用變量而不是特定的詞來替換它嗎?例如String test =「dogs」; http://www.google.com/search?q=test – User 2012-07-27 03:34:16