有道词典
来源:互联网 发布:苹果绿色上网软件注册 编辑:程序博客网 时间:2024/06/10 15:07
1.xml代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bj"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/btnSearch"
android:layout_toRightOf="@+id/etWord"
android:layout_marginLeft="10dip"
android:layout_width="fill_parent"
android:layout_height="45dip"
android:layout_weight="1"
android:background="@drawable/an"
android:onclick="CheckWord"
android:onClick="searchWord" />
<EditText
android:id="@+id/etWord"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:background="@android:drawable/edit_text"
android:ems="10"
android:singleLine="true"
android:textColor="#552006"
android:textColorHint="#782f10" />
<WebView
android:id="@+id/wvSearchResult"
android:layout_width="fill_parent"
android:layout_height="120dip"
android:layout_alignParentBottom="true"
android:layout_below="@id/etWord"
android:layout_marginTop="10dip"
android:layout_weight="1" />
</RelativeLayout>
2.mainactivity 代码
public void CheckWord(View view){ String etURL=etWord.getText().toString(); etURL=etURL.trim(); if(!TextUtils.isEmpty(etURL)){ String path="http://dict.youdao.com/m/search?keyfrom=dict.mindex&q="+etURL; wvView.loadUrl(path); wvView.setWebViewClient(new HelloWebViewClient ()); }else{ Toast.makeText(this, "请填写单词", Toast.LENGTH_LONG).show(); } } private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }
3.AndroidManifest.xml 添加网络权限
<uses-permission android:name="android.permission.INTERNET" />
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 有道词典
- 通过禁用javascript给Eclipse加速
- 中介者模式(Mediator)
- luasocket系列之winsocket基础补充_TcpServerDemo
- IOS 开发环境,证书和授权文件
- C# 集合类 :(Array、 Arraylist、List、Hashtable、Dictionary、Stack、Queue)
- 有道词典
- WARNING: CAN’T OPEN CONFIG FILE: /USR/LOCAL/SSL/OPENSSL.CNF
- Debug 调试详解
- javassis在spring初始化前修改class文件。
- 解释器模式(Interpreter)
- EGOCache缓存框架详细讲解
- hibernate 注解
- 牛腩新闻发布系统(3)——盒子模型
- iOS开发:创建真机调试证书