词典
来源:互联网 发布:origin导入excel数据 编辑:程序博客网 时间:2024/04/27 13:26
- 1.布局文件
- <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="27dp"
- android:background="@android:drawable/edit_text"
- android:ems="10"
- android:singleLine="true"
- android:textColor="#552006"
- android:textColorHint="#782f10" >
- <requestFocus />
- </EditText>
- <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="22dp"
- android:background="@drawable/bg_roundcorner"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textSize="25sp" />
- <Button
- android:id="@+id/btnSearch"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_above="@+id/wvSearchResult"
- android:layout_alignParentRight="true"
- android:background="@drawable/ibsearchword"
- android:onClick="searchWord" />
- </RelativeLayout>
2.代码
- private void initViews() {
- etWord = (EditText) findViewById(R.id.etWord);
- wvResult = (WebView) findViewById(R.id.wvSearchResult);
- wvResult.setWebViewClient(new WebViewClient() {
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, String url) {
- view.loadUrl(url);
- return true;
- }
- });
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
- public void searchWord(View view) {
- String word = etWord.getText().toString();
- if (TextUtils.isEmpty(word)) {
- Toast.makeText(this, "查询内容不能为空!", Toast.LENGTH_LONG).show();
- } else {
- final String strUrl = "http://dict.youdao.com/m/search?keyfrom=dict.mindex&vendor=&q="
- + word;
- wvResult.loadUrl(strUrl);
- }
- }
- }
0 0
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典
- 词典--词典树,检索
- 程序员词典
- 音乐播放器
- C语言中可变参数的用法
- Introduce to algorithm-----pseudo code to C/C++ code (chapter 11)
- boxplot--盒图
- Sizeof与Strlen的区别与联系
- 词典
- 用jsp写一个动态表格
- 动态规划:从新手到专家(关于动态规划算法最精彩的中文描述,没有之一)
- 【计算机网络学习】之TCP和UDP比较
- UIApplication sharedApplication详细解释-IOS
- tyvj-1460 旅行
- 记住密码
- C++atoi与atof
- App开发到App Store上架,发布流程。