WebView调用有道词典实现在线查词
来源:互联网 发布:餐饮软件故障 编辑:程序博客网 时间:2024/05/01 23:49
WebView(网络视图)能加载显示网页,可以将其视为一个浏览器。它使用了WebKit渲染引擎加载显示网页,使用方法很简单,直接在XML文件中写入webview控件即可,主要代码如下:
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <EditText android:id="@+id/editText" android:layout_width="150px" android:layout_height="40px" android:layout_x="5px" android:layout_y="32px" android:textSize="18sp" /> <Button android:id="@+id/btnsearch" android:layout_width="60px" android:layout_height="40px" android:layout_x="165px" android:layout_y="35px" android:text="查看" /> <WebView android:id="@+id/reswebView" android:layout_width="300px" android:layout_height="330px" android:layout_x="7px" android:layout_y="90px" android:focusable="false" /></AbsoluteLayout>
程序执行顺序为,先取到edittext控件的内容,判断内容是否为空,不为空则提交到WebView中。
代码如下:
btnSearch = (Button) findViewById(R.id.btnsearch);btnSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String strUri = editText.getText().toString(); strUri = strUri.trim(); if (strUri.length() == 0) { Toast.makeText(getApplicationContext(), "请输入查询字符", 1).show(); } else { String strURL = "http://dict.youdao.com/m/search?keyfrom=dict.mindex&q=" + strUri; reswebView.loadUrl(strURL); } }});
主要就是调用webview的loadUrl方法,效果截图:
0 0
- WebView调用有道词典实现在线查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- 调用有道词典查词
- WebView实现有道词典
- linux下借助有道在线词典查词
- 调用有道词典的在线书店
- android :调用有道词典查字词
- java IO流操作inoutstream和outputstream读写操作
- magento -- 使用translate.csv来修改翻译
- android中知道图片name时获取图片的简单方法
- Objective-C分类 (category)和扩展(Extension)
- Hibernate 参数设置一览表
- WebView调用有道词典实现在线查词
- Android 之窗口小部件详解--App Widget
- select的种种取值
- memmove和memcpy
- OC的各种打印
- Java实现循环列表,解决约瑟夫环问题,java循环链表分析,链表分析了一下
- Oracle专家谈MySQL Cluster如何支持200M的QPS
- 关于Ibatis的isNotEmptyproperty的理解
- Android安全输入设计与思考