位置: 编程技术 - 正文

仿有道词典(有道词典下载安装)

编辑:rootadmin

推荐整理分享仿有道词典(有道词典下载安装),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:有道词典在线下载,有道词典安卓下载,有道词典hd免费下载,有道词典有道词典下载,有道词典有道词典下载,有道.词典,有道词典有道词典下载,有道词典有道词典下载,内容如对您有帮助,希望把文章链接给更多的朋友!

1、效果图如图所示

2、主要通过webview控件实现仿有道词典的功能

布局文件代码

1、<RelativeLayout xmlns:android=" xmlns:tools=" android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@drawable/mainbg"

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" >

<EditText

android:id="@&#;id/etWord"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentLeft="true"

android:layout_alignParentTop="true"

android:layout_marginTop="dp"

android:background="@android:drawable/edit_text"

android:ems=""

android:singleLine="true"

android:textColor="#"

android:textColorHint="#f" >

<requestFocus />

</EditText>

<Button

android:id="@&#;id/btnSearch"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignRight="@&#;id/tvSearchResult"

android:layout_alignTop="@&#;id/etWord"

android:background="@drawable/ibsearchword"

android:onClick="search" />

<WebView

android:id="@&#;id/wvSearchResult"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:layout_alignLeft="@&#;id/etWord"

android:layout_below="@&#;id/etWord"

android:layout_marginTop="dp"

android:background="@drawable/bg_roundcorner"

android:textAppearance="?android:attr/textAppearanceMedium"

android:textSize="sp" />

</RelativeLayout>

2、mainactivity.xml文件

public class YouDao extends Activity

{

//查询按钮申明

仿有道词典(有道词典下载安装)

private Button myButton;

//清空按钮申明

private Button myButton;

//输入框申明

private EditText mEditText1;

//加载数据的WebView申明

private WebView mWebView1;

public void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

//获得布局的几个控件

myButton = (Button)findViewById(R.id.myButton);

myButton = (Button) findViewById(R.id.myButton);

mEditText1 = (EditText) findViewById(R.id.myEditText1);

mWebView1 = (WebView) findViewById(R.id.myWebView1);

//查询按钮添加事件

myButton.setOnClickListener(new Button.OnClickListener()

{

public void onClick(View arg0)

{

String strURI = (mEditText1.getText().toString());

strURI = strURI.trim();

//如果查询内容为空提示

if (strURI.length() == 0)

{

Toast.makeText(YouDao.this, "查询内容不能为空!", Toast.LENGTH_LONG)

.show();

}

//否则则以参数的形式从 else

{

String strURL = " &#; strURI;

mWebView1.loadUrl(strURL);

}

}

});

//清空按钮添加事件,将EditText置空

myButton.setOnClickListener(new Button.OnClickListener()

{

public void onClick(View v)

{

mEditText1.setText("");

}

});

}

private void findByid() { // TODO Auto-generated method stub etWord=(EditText) findViewById(R.id.etWord); btnYes=(Button) findViewById(R.id.btnSelect); btnNo=(Button) findViewById(R.id.btnDelete); wvWord = (WebView) findViewById(R.id.wvShow); } //web视图 class WebViewClient extends WebViewClient { public boolean shouldOverviewUrlLoading(WebView view,String url) { view.loadUrl(url); return true; }}

}

3、必须在AndroidManifest.xml加上联网权限

<uses-permission android:name="android.permission.INTERNET"/>

版权声明:本文为博主原创文章,未经博主允许不得转载。

Android支持百分比布局 Google支持了百分比布局,使用方法很简单1.将你的SDK更新至最新2.在你的build.gradle文件加入dependencies{compile'com.android.support:percent:.2.0'}使用案例:

[置顶] android自定义换行居中CenterTextView 在我们开发app时,TextView一定是使用最多的控件了,android自带的TextView的功能也十分强大,但还是有些小的地方不能满足我们的需求,几天要说的这个功

Android-ContentProvider使用 Android-ContentProvider使用一建立ContentProvider服务器端1建立一个继承自ContentProvider的类并重写接口方法(这里仅打一些log做代表)packagecom.chengzhi.androidcontentprovi

本文链接地址:https://www.jiuchutong.com/biancheng/379606.html 转载请保留说明!

上一篇:Android 常用RGB值以及中英文名称(android颜色值)

下一篇:Android支持百分比布局(安卓百分百)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络