http://www.ways2u.com/?post=184

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right"
>
<TextView
android:layout_marginTop="10px"
android:id="@+id/l_about"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="20sp"
android:gravity="center_horizontal"
android:typeface="sans"
/>
<EditText
android:layout_marginTop="10px"
android:id="@+id/tinput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="输入要翻译的词或句子"
/>
<Button
android:layout_marginTop="10px"
android:id="@+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" 开始翻译 "
/>
<TextView
android:id="@+id/tips"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="翻译结果如下:"
android:textSize="14sp"
android:typeface="sans"
android:visibility="invisible"
/>
<WebView
android:layout_marginTop="10px"
android:id="@+id/toutput"
android:layout_width="fill_parent"
android:layout_height="270px"
android:visibility="invisible"
/>
</LinearLayout>
package com.hl.dict;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class DICTTranslater extends Activity {
private TextView tips;
private EditText editText;
private WebView webView;
private Handler tHandler = new Handler();

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView=(WebView)findViewById(R.id.toutput);
final Button submit=(Button)findViewById(R.id.submit);
editText=(EditText)findViewById(R.id.tinput);
tips=(TextView)findViewById(R.id.tips);

WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setSaveFormData(false);
webSettings.setSavePassword(false);
webSettings.setSupportZoom(false);
submit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tips.setVisibility(TextView.VISIBLE);
webView.setVisibility(WebView.VISIBLE);
tHandler.post(new Runnable(){
public void run(){
if (editText.getText().toString() != ""){
webView.loadUrl("http://dict.cn/mini.php?q="+ editText.getText().toString());
}
}
});
}
});
}
}

更多相关文章

  1. Android九宫格解锁的实现
  2. Android简易计算器(破烂Alpha版,后续更新)
  3. Android自学笔记(番外篇):全面搭建Linux环境(五)——Eclipse Helios(3.
  4. EditText实时判断输入字符数
  5. Android通过手势实现图像拖拽功能
  6. Android(安卓)dependency ‘androidx.core:core’ has different
  7. android中调用金山词霸
  8. Android(安卓)5.1截获HOME键
  9. android 解析xml

随机推荐

  1. linux(Centos7)下安装mysql8.0.18的教程图
  2. MySQL中NOT IN填坑之列为null的问题解决
  3. mysql 8.0.18 安装配置图文教程
  4. Ubuntu查看修改mysql的登录名和密码、安
  5. 解决mysql登录错误:&#39;Access denied fo
  6. mysql 定时任务的实现与使用方法示例
  7. MySQL字符串索引更合理的创建规则讨论
  8. 使用limit,offset分页场景时为什么会慢
  9. MySQL控制用户输错密码尝试次数
  10. mysql命令行脚本执行操作示例