android :调用有道词典查字词
来源:互联网 发布:河海大学网络教育 编辑:程序博客网 时间:2024/04/26 05:56
1. activity_main.xml布局
1 <EditText 2 android:id="@+id/etWord" 3 android:layout_width="wrap_content" 4 android:layout_height="wrap_content" 5 android:layout_alignParentLeft="true" 6 android:layout_alignParentTop="true" 7 android:ems="10" > 8 9 <requestFocus />10 </EditText>11 12 <Button13 android:id="@+id/btnCheck"14 android:onClick="CheckWord"15 android:layout_width="wrap_content"16 android:layout_height="wrap_content"17 android:layout_alignBaseline="@+id/editText1"18 android:layout_alignBottom="@+id/editText1"19 android:layout_alignParentRight="true"20 android:text="查看" />21 22 <WebView23 android:id="@+id/wvView"24 android:layout_width="match_parent"25 android:layout_height="match_parent"26 android:layout_below="@+id/btnCheck"27 android:layout_centerHorizontal="true" />2. MainActivity.java 中主要代码(findViewbyId省略)
1 public void CheckWord(View view){ 2 3 String etURL=etWord.getText().toString(); 4 etURL=etURL.trim(); 5 if(!TextUtils.isEmpty(etURL)){ 6 String path="http://dict.youdao.com/m/search?keyfrom=dict.mindex&q="+etURL; 7 wvView.loadUrl(path); 8 wvView.setWebViewClient(new HelloWebViewClient ()); 9 10 }else{ 11 12 Toast.makeText(this, "单词不能为空", Toast.LENGTH_LONG).show(); 13 } 14 15 } 16 private class HelloWebViewClient extends WebViewClient { 17 @Override 18 public boolean shouldOverrideUrlLoading(WebView view, String url) { 19 view.loadUrl(url); 20 return true; 21 } 22 }3. XML布局中的Button 加入以下代码, CheckWord 为 MainActivity.java中的函数
android:onClick="CheckWord"
4.在 AndroidManifest.xml 中设置网络权限
<uses-permission android:name="android.permission.INTERNET" />
0 0
- android :调用有道词典查字词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- WebView调用有道词典实现在线查词
- 调用有道词典查询
- android中的有道词典
- Android有道词典开发
- gvim Gtk-WARNING **: Invalid input string错误的解决办法
- 跨终端实践-天猫试戴的解决方案
- 安装XAMPP 警示
- 一切成功源于积累——20150703 澳美大虐杀 六年最低点
- 整数溢出
- android :调用有道词典查字词
- 【WebService异常分析】
- stl之set集合容器应用基础
- Ubuntu中的热键感悟
- 百度富文本 uEditor 调用不到,解决办法
- OC字符串操作方法
- 源起自动化
- caffe-ubuntu14.04+64bit环境配置说明(GPU下运行)
- leetcode-105&106 Construct Binary Tree from Preorder and Inorder Traversal I&II