1、布局文件main.xml
<?xml version="1.0" encoding="utf-8"?>
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@+id/editTextid"
android:layout_width="200px"
android:layout_height="wrap_content"
android:layout_x="5px"
android:layout_y="32px"
/>


主程序
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class YoudaoActivity extends Activity {
/** Called when the activity is first created. */
private EditText editString;
private Button query;
private Button clear;
private WebView webview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

query = (Button)findViewById(R.id.query);
clear = (Button)findViewById(R.id.clear);

query.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
editString = (EditText)findViewById(R.id.editTextid);
String strURL = editString.getText().toString();
strURL = strURL.trim();
webview = (WebView)findViewById(R.id.webViewId);
if (strURL.length() == 0) {
Toast.makeText(YoudaoActivity.this, "查询内容不能为空!", Toast.LENGTH_LONG).show();
}
else
{
String url = "http://dict.youdao.com/m/search?keyfrom=dict.mindex&q="+strURL;
webview.loadUrl(url);
}
}
});
clear.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
editString.setText("");
}
});
}
}

更多相关文章

  1. Android(安卓)3.1 r1 中文API文档 (120) —— SearchView
  2. android中的有道词典实例
  3. android 注册、登录实现程序
  4. android 注册、登录实现程序
  5. Android(安卓)Contacts的使用(一)
  6. android 逐帧动画
  7. 设置Android(安卓)app背景图片(Android(安卓)studio)
  8. android HTTPURLConnection解决不能访问HTTPs请求
  9. android lisetview的多列模版

随机推荐

  1. pc端telegram使用方法2021
  2. php 中文网 第十五期——第二课作业
  3. thinkphp上传文件保存2个不同尺寸的图片
  4. 课程表学习代码发布
  5. 表单的练习
  6. Java并发编程学习笔记2
  7. Puppet自动化集群管理进阶篇
  8. 用 Go 构建一个 SQL 解析器
  9. 浅谈Cgroups V2
  10. istio组件mixer初学篇