一.项目功能简介

电子词典具有离线查询和在线查询两种功能,离线查询不用联网就可以查询到单词的释义,不过,只能查询本数据库中的一些单词,查询不到的单词是因为本数据库中没有,所以这一缺点还有待改进;如果想查询离线查不到的单词,可使用在线查询,词典会调用有道词典在线解答,会有更多的释义。此APP还有很多不足之处,还有待改进。

词典数据保存在小型数据库sqlite中,在res的raw文件夹下。

二.运行效果图

APPt图标                                                                  APP引导界面                                                                              离线 查询界面

查询结果以对话框的形式显示                                      生词本界面通过listvtew展示                                                             在线查询界面

在线查询调用有道词典界面

三 .项目源码

EditWord.java

//电子词典的编辑界面文件,输入单词可查询。

package com.example.dictionary;import java.util.ArrayList;
import java.util.HashMap;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.SimpleAdapter;
import android.widget.Toast;public class EditWord extends Activity implements OnClickListener {private String action;private EditText zhushi;private EditText meanning;private Button confirm;private Button cancel;int index = -1;private Bundle bundle;private ArrayList<HashMap<String, String>> arrayList;@SuppressWarnings("unchecked")protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);// 设置隐藏标题requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.edit);Bundle bundle = this.getIntent().getExtras();action = bundle.getString("action");initWidgets();}private void initWidgets() {// spelling是单词,meanning是解释,confirm是确定,cancel是取消zhushi = (EditText) findViewById(R.id.zhushi);meanning = (EditText) findViewById(R.id.meanning);confirm = (Button) findViewById(R.id.button1);cancel = (Button) findViewById(R.id.button2);cancel.setOnClickListener(this);confirm.setOnClickListener(this);}@Overrideprotected void onResume() {// TODO Auto-generated method stubsuper.onResume();if (action.equals("edit")) {zhushi.setText(bundle.getString("word"));meanning.setText(bundle.getString("explain"));index = bundle.getInt("index");}}@SuppressWarnings("unchecked")@Overridepublic void onClick(View v) {// TODO Auto-generated method stubString word = meanning.getText().toString().trim();String explain = zhushi.getText().toString().trim();if (v == cancel) {finish();}if (v == confirm) {if (meanning.getText().toString().equals("")|| zhushi.getText().toString().equals("")) {Toast.makeText(EditWord.this, "信息不能为空", Toast.LENGTH_SHORT).show();}else {Intent intent = getIntent();arrayList = (ArrayList<HashMap<String, String>>) new ObjectFile().readObjectFile();if (null == arrayList) {arrayList = new ArrayList<HashMap<String, String>>();}if (!TextUtils.isEmpty(word) && !TextUtils.isEmpty(explain)) {if (index == -1) {HashMap<String, String> map = new HashMap<String, String>();map.put("word", word);map.put("explain", explain);arrayList.add(map);}else{HashMap<String, String> map = new HashMap<String, String>();map.put("word", word);map.put("explain", explain);arrayList.set(index, map);}new ObjectFile().writeObjectFile(arrayList);}SimpleAdapter adapter = new SimpleAdapter(this, arrayList,android.R.layout.simple_list_item_2, new String[] {"word", "explain" }, new int[] {android.R.id.text1, android.R.id.text2 });Intent intent1 = new Intent(this, MainActivity.class);intent.putExtra("word", word);intent.putExtra("explain", explain);startActivity(intent1);EditWord.this.finish();}}}
}

HomeActivity.java

//电子词典的开始引导界面文件

package com.example.dictionary;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.Window;
import android.view.WindowManager;public class HomeActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);//设置隐藏标题栏requestWindowFeature(Window.FEATURE_NO_TITLE);//设置全屏this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);setContentView(R.layout.home);new Thread(new Runnable(){@Overridepublic void run() {// TODO Auto-generated method stubtry {Thread.sleep(1000);shiftActivityToHome();} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}).start();}private void shiftActivityToHome(){Intent intent=new Intent(HomeActivity.this,MainActivity.class);startActivity(intent);//把当前也关闭HomeActivity.this.finish();}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}}

MainActivity.java

package com.example.dictionary;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.Window;
import android.view.WindowManager;public class HomeActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);//设置隐藏标题栏requestWindowFeature(Window.FEATURE_NO_TITLE);//设置全屏this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);setContentView(R.layout.home);new Thread(new Runnable(){@Overridepublic void run() {// TODO Auto-generated method stubtry {Thread.sleep(1000);shiftActivityToHome();} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}).start();}private void shiftActivityToHome(){Intent intent=new Intent(HomeActivity.this,MainActivity.class);startActivity(intent);//把当前也关闭HomeActivity.this.finish();}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}}

NoteBook.java

//生词本界面文件,将生词标记然后添加到生词本使用ListView控件展示。

package com.example.dictionary;import java.util.ArrayList;
import java.util.HashMap;import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;public class NoteBook extends Activity {public static final int MENU_ADD = 1;public static final int MENU_TUICHU = MENU_ADD + 1;private ArrayList<HashMap<String, String>> arrayList;private ListView listView1;@SuppressWarnings("unchecked")@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.note_book);listView1 = (ListView) findViewById(R.id.listView1);}@Overrideprotected void onResume() {// TODO Auto-generated method stubsuper.onResume();Intent intent = getIntent();final String word = intent.getStringExtra("word");final String explain = intent.getStringExtra("explain");arrayList = (ArrayList<HashMap<String, String>>) new ObjectFile().readObjectFile();if (null == arrayList) {arrayList = new ArrayList<HashMap<String, String>>();}if (!TextUtils.isEmpty(word) && !TextUtils.isEmpty(explain)) {HashMap<String, String> map = new HashMap<String, String>();map.put("word", word);map.put("explain", explain);arrayList.add(map);new ObjectFile().writeObjectFile(arrayList);}final SimpleAdapter adapter = new SimpleAdapter(this, arrayList,android.R.layout.simple_list_item_2, new String[] { "word","explain" }, new int[] { android.R.id.text1,android.R.id.text2 });listView1.setAdapter(adapter);// 为listView1视图添加setOnItemClickListener监听listView1.setOnItemClickListener(new AdapterView.OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> arg0, View arg1,final int arg2, long arg3) {// 对于选中的项进行处理AlertDialog.Builder builder = new Builder(NoteBook.this);builder.setIcon(R.drawable.dialog_icon);builder.setMessage("确认操作");builder.setTitle("提示");builder.setPositiveButton("删除", new OnClickListener() {public void onClick(DialogInterface dialog, int which) {arrayList.remove(arg2);new ObjectFile().writeObjectFile(arrayList);adapter.notifyDataSetChanged();dialog.dismiss();}});builder.setNeutralButton("编辑", new OnClickListener() {public void onClick(DialogInterface dialog, int which) {
//                      Intent intent = new Intent();
//                      Bundle bundle = new Bundle();
//                      bundle.putString("word", word);
//                      bundle.putString("explain", explain);
//                      intent.putExtras(bundle);
//                      intent.setClass(NoteBook.this, EditWord.class);
//                      startActivity(intent);
//                      dialog.dismiss();}});builder.setNegativeButton("取消", null).show();// TODO Auto-generated method stub}});}public boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.menu.add(0, MENU_ADD, 0, "添加新单词");menu.add(0, MENU_TUICHU, 1, "退出");return super.onCreateOptionsMenu(menu);}public boolean onOptionsItemSelected(MenuItem item) {switch (item.getItemId()) {case MENU_ADD: {Intent intent = new Intent();Bundle bundle = new Bundle();bundle.putString("action", "add");intent.putExtras(bundle);intent.setClass(this, EditWord.class);startActivity(intent);break;}case MENU_TUICHU: {finish();}}return super.onOptionsItemSelected(item);}}

ObjectFile.java

package com.example.dictionary;import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;public class ObjectFile {private String path = "/sdcard/word/word.txt";public File createFile() {File file = new File(path);File parentFile = file.getParentFile();if (!parentFile.exists()) {parentFile.mkdirs();}if (!file.exists()) {try {file.createNewFile();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}return file;}public Object readObjectFile() {ObjectInputStream mis = null;Object mObject = null;File file = new File(path);if (!file.exists()) {return null;} else {try {mis = new ObjectInputStream(new FileInputStream(file));mObject = mis.readObject();mis.close();} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}return mObject;}}public void DeleteObjectFile(Object object){}public boolean writeObjectFile(Object object) {ObjectOutputStream mos = null;try {mos = new ObjectOutputStream(new FileOutputStream(createFile()));mos.writeObject(object);mos.close();} catch (Exception e) {// TODO: handle exceptione.printStackTrace();return false;}return true;}
}

OfflineQuery.java

//离线查询单词界面文件,调用本地数据库,只能查询到数据库中有的单词,数据库中没有的将无法查询到。

package com.example.dictionary;import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;import com.iflytek.speech.RecognizerResult;
import com.iflytek.speech.SpeechError;
import com.iflytek.ui.RecognizerDialog;
import com.iflytek.ui.RecognizerDialogListener;import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.CursorAdapter;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;public class OfflineQuery extends Activity implements OnClickListener,TextWatcher {public static final int MENU_ABOUT = 1;public static final int MENU_TUICHU = MENU_ABOUT + 2;private final String DATABASE_PATH = android.os.Environment.getExternalStorageDirectory().getAbsolutePath() + "/dictionary";private AutoCompleteTextView actvWord;private final String DATABASE_FILENAME = "dictionary.db";private SQLiteDatabase database;private Button btnSelectWord;private Button Clear;private TextView mTextView;private String result;private ArrayList<HashMap<String, String>> arrayList;public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.offline_query);database = openDatabase();btnSelectWord = (Button) findViewById(R.id.ButtonGo);actvWord = (AutoCompleteTextView) findViewById(R.id.seek);Clear = (Button) findViewById(R.id.clearButton);btnSelectWord.setOnClickListener(this);actvWord.addTextChangedListener(this);Clear.setOnClickListener(new Button.OnClickListener() {public void onClick(View v) {actvWord.setText("");}});}public class DictionaryAdapter extends CursorAdapter {private LayoutInflater layoutInflater;public CharSequence convertToString(Cursor cursor) {return cursor == null ? "" : cursor.getString(cursor.getColumnIndex("_id"));}private void setView(View view, Cursor cursor) {TextView tvWordItem = (TextView) view;tvWordItem.setText(cursor.getString(cursor.getColumnIndex("_id")));tvWordItem.setPadding(15, 10, 10, 15);tvWordItem.setTextSize(18);}public DictionaryAdapter(Context context, Cursor c, boolean autoRequery) {super(context, c, autoRequery);// TODO Auto-generated constructor stublayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);}@Overridepublic void bindView(View view, Context context, Cursor cursor) {// TODO Auto-generated method stubsetView(view, cursor);}@Overridepublic View newView(Context context, Cursor cursor, ViewGroup parent) {// TODO Auto-generated method stubView view = new TextView(OfflineQuery.this);setView(view, cursor);return view;}}private SQLiteDatabase openDatabase() {try {// 获得dictionary.db文件的绝对路径String databaseFilename = DATABASE_PATH + "/" + DATABASE_FILENAME;File dir = new File(DATABASE_PATH);// 如果/sdcard/dictionary目录中存在,创建这个目录if (!dir.exists())dir.mkdir();// 如果在/sdcard/dictionary目录中不存在// dictionary.db文件,则从res\raw目录中复制这个文件到// SD卡的目录(/sdcard/dictionary)if (!(new File(databaseFilename)).exists()) {// 获得封装dictionary.db文件的InputStream对象InputStream is = getResources().openRawResource(R.raw.dictionary);FileOutputStream fos = new FileOutputStream(databaseFilename);byte[] buffer = new byte[8192];int count = 0;// 开始复制dictionary.db文件while ((count = is.read(buffer)) > 0) {fos.write(buffer, 0, count);}fos.close();is.close();}// 打开/sdcard/dictionary目录中的dictionary.db文件SQLiteDatabase database = SQLiteDatabase.openOrCreateDatabase(databaseFilename, null);return database;} catch (Exception e) {}return null;}public void afterTextChanged(Editable s) {// 必须将english字段的别名设为_idCursor cursor = database.rawQuery("select english as _id from t_words where english like ?",new String[] { s.toString() + "%" });DictionaryAdapter dictionaryAdapter = new DictionaryAdapter(this,cursor, true);actvWord.setAdapter(dictionaryAdapter);}public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,int arg3) {// TODO Auto-generated method stub}public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {// TODO Auto-generated method stub}public void onClick(View view) {// TODO Auto-generated method stubString sql = "select chinese from t_words where english=?";Cursor cursor = database.rawQuery(sql, new String[] { actvWord.getText().toString() });result = "未找到该单词.";// 如果查找单词,显示其中文的意思if (cursor.getCount() > 0) {// 必须使用moveToFirst方法将记录指针移动到第1条记录的位置cursor.moveToFirst();result = cursor.getString(cursor.getColumnIndex("chinese"));}if (actvWord.getText().toString().equals("")) {Toast.makeText(OfflineQuery.this, "查询内容不能为空!", Toast.LENGTH_LONG).show();return;}// 显示查询结果对话框new AlertDialog.Builder(this).setIcon(R.drawable.dialog_icon).setTitle("查询结果").setMessage(result).setPositiveButton("加入生词本",new DialogInterface.OnClickListener() {@SuppressWarnings("unchecked")@Overridepublic void onClick(DialogInterface dialog,int which) {Intent intent = getIntent();if (!result.equals("未找到该单词.")) {String word = actvWord.getText().toString().trim();String explain = result;arrayList = (ArrayList<HashMap<String, String>>) new ObjectFile().readObjectFile();if (null == arrayList) {arrayList = new ArrayList<HashMap<String, String>>();}if (!TextUtils.isEmpty(word)&& !TextUtils.isEmpty(result)) {HashMap<String, String> map = new HashMap<String, String>();map.put("word", word);map.put("explain", result);arrayList.add(map);new ObjectFile().writeObjectFile(arrayList);}}}}).setNegativeButton("关闭", null).show();SimpleAdapter adapter = new SimpleAdapter(this, arrayList,android.R.layout.simple_list_item_2, new String[] { "word","explain" }, new int[] { android.R.id.text1,android.R.id.text2 });}// 语音部分private static final String APPID = "appid=4f2d3a06";private String text = "";public void say(View view) {RecognizerDialog isrDialog = new RecognizerDialog(this, APPID);/** 设置引擎目前支持五种 ”sms”:普通文本转写 “poi”:地名搜索 ”vsearch”:热词搜索 ”video”:视频音乐搜索* ”asr”:命令词识别*/isrDialog.setEngine("sms", null, null);isrDialog.setListener(recoListener);isrDialog.show();}// 语言识别监听器,有两个方法RecognizerDialogListener recoListener = new RecognizerDialogListener() {@Overridepublic void onResults(ArrayList<RecognizerResult> results,boolean isLast) {// 服务器识别完成后会返回集合,我们这里就只得到最匹配的那一项text = results.get(0).text;System.out.println(text);}@Overridepublic void onEnd(SpeechError error) {if (error == null) {// 完成后就把结果显示在EditText上actvWord.setText(text);}}};@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.menu.add(0, MENU_ABOUT, 0, "说明");menu.add(0, MENU_TUICHU, 1, "退出");return super.onCreateOptionsMenu(menu);}public boolean onOptionsItemSelected(MenuItem item) {switch (item.getItemId()) {case MENU_ABOUT: {Intent intent = new Intent();intent.setClass(this, About.class);startActivity(intent);break;}case MENU_TUICHU: {finish();}}return super.onOptionsItemSelected(item);}
}

OnlineQuery.java

//在线查询界面文件,在线查询将会调用有道词典对单词进行释义。

package com.example.dictionary;import java.util.ArrayList;import com.iflytek.speech.RecognizerResult;
import com.iflytek.speech.SpeechError;
import com.iflytek.ui.RecognizerDialog;
import com.iflytek.ui.RecognizerDialogListener;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebView;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.Toast;public class OnlineQuery extends Activity{private Button ButtonGo;private AutoCompleteTextView seek;private WebView myWebView1;private Button clearButton;public static final int MENU_ABOUT = 1;public static final int MENU_TUICHU = MENU_ABOUT + 2;public void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);setContentView(R.layout.online_query);ButtonGo = (Button)findViewById(R.id.ButtonGo);seek = (AutoCompleteTextView) findViewById(R.id.seek);clearButton = (Button)findViewById(R.id.clearButton);myWebView1 = (WebView)findViewById(R.id.myWebView1);ButtonGo.setOnClickListener(new Button.OnClickListener(){@Overridepublic void onClick(View arg0) {String strURI = (seek.getText().toString());strURI = strURI.trim();if(strURI.length()==0){Toast.makeText(OnlineQuery.this, "查询内容不能为空!", Toast.LENGTH_LONG).show();}else {String strURL = "http://dict.youdao.com/m/search?keyfrom=dict.mindex&q="+strURI;myWebView1.loadUrl(strURL);}}});http://dict.youdao.com/m/serch?keyfrom=dict.mindex&vendor=%24vendor&q=happyclearButton.setOnClickListener(new Button.OnClickListener(){public void onClick(View v){seek.setText("");}});
}
//语音部分private static final String APPID = "appid=4f2d3a06";private String text=""; public void say(View view) {RecognizerDialog isrDialog = new RecognizerDialog(this, APPID);/** 设置引擎目前支持五种 ”sms”:普通文本转写 “poi”:地名搜索 ”vsearch”:热词搜索 ”video”:视频音乐搜索* ”asr”:命令词识别*/isrDialog.setEngine("sms", null, null);isrDialog.setListener(recoListener);isrDialog.show();}// 语言识别监听器,有两个方法RecognizerDialogListener recoListener = new RecognizerDialogListener() {@Overridepublic void onResults(ArrayList<RecognizerResult> results,boolean isLast) {// 服务器识别完成后会返回集合,我们这里就只得到最匹配的那一项text = results.get(0).text;System.out.println(text);}@Overridepublic void onEnd(SpeechError error) {if (error == null) {// 完成后就把结果显示在EditText上seek.setText(text);}}};public boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.menu.add(0, MENU_ABOUT, 0, "说明");menu.add(0, MENU_TUICHU, 1, "退出");return super.onCreateOptionsMenu(menu);}public boolean onOptionsItemSelected(MenuItem item) {switch (item.getItemId()) {case MENU_ABOUT: {Intent intent = new Intent();intent.setClass(this, About.class);startActivity(intent);break;}case MENU_TUICHU: {finish();}}return super.onOptionsItemSelected(item);}
}

四.布局文件

Dier.xml

<?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@android:id/tabhost"     android:layout_width="fill_parent"     android:layout_height="fill_parent">
<LinearLayoutandroid:orientation="vertical"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:padding="5dp">
<TabWidgetandroid:id="@android:id/tabs" android:layout_width="fill_parent"             android:layout_height="wrap_content" />
<FrameLayout             android:id="@android:id/tabcontent"             android:layout_width="fill_parent"             android:layout_height="fill_parent"             android:padding="5dp" ><TextViewandroid:id="@+id/textView1"android:layout_width="fill_parent"android:layout_height="fill_parent"></TextView><TextViewandroid:id="@+id/textView2"android:layout_width="wrap_content"android:layout_height="wrap_content"/><TextViewandroid:id="@+id/textView3"android:layout_width="wrap_content"android:layout_height="wrap_content"/></FrameLayout>     </LinearLayout>
</TabHost>

Edit.xml

//编辑界面

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:background="@drawable/bg" ><TextViewandroid:id="@+id/spelling"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignBaseline="@+id/meanning"android:layout_alignBottom="@+id/meanning"android:layout_alignParentLeft="true"android:background="@drawable/meanning" /><EditTextandroid:id="@+id/meanning"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:layout_alignParentTop="true"android:layout_toRightOf="@+id/spelling"android:ems="10"android:hint="单词拼写" /><TextViewandroid:id="@+id/note"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentTop="true"android:layout_marginTop="59dp"android:background="@drawable/zhushi" /><EditTextandroid:id="@+id/zhushi"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignLeft="@+id/meanning"android:layout_alignParentRight="true"android:layout_below="@+id/meanning"android:ems="10"android:hint="中文解释" /><Buttonandroid:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignBaseline="@+id/button1"android:layout_alignBottom="@+id/button1"android:layout_alignParentRight="true"android:background="@drawable/quxiao" /><Buttonandroid:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/zhushi"android:layout_marginTop="24dp"android:background="@drawable/queding" /></RelativeLayout>

Home.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><TextViewandroid:id="@+id/textView1"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/start"android:textAppearance="?android:attr/textAppearanceLarge" /></LinearLayout>

Note_book.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/bg"android:orientation="vertical" ><TextViewandroid:id="@+id/book"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="@drawable/header"android:paddingTop="15dp"android:text="@string/back"android:textAppearance="?android:attr/textAppearanceLarge" /><ListViewandroid:id="@+id/listView1"android:layout_width="match_parent"android:layout_height="wrap_content" ></ListView></LinearLayout>

Offline_query.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal" ><Buttonandroid:id="@+id/ButtonVoice"style="?android:attr/buttonStyleSmall"android:layout_width="50dp"android:layout_height="50dp"android:background="@drawable/voice"android:onClick="say" /><AutoCompleteTextViewandroid:id="@+id/seek"android:layout_width="155dp"android:layout_height="wrap_content"android:completionThreshold="1"android:ems="10"android:textColor="#000000" ><requestFocus /></AutoCompleteTextView><Buttonandroid:id="@+id/ButtonGo"android:layout_width="50dp"android:layout_height="50dp"android:background="@drawable/ok" /><Buttonandroid:id="@+id/clearButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/img4"android:textSize="15sp" /></LinearLayout><TextViewandroid:id="@+id/imageView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/imageview" /></LinearLayout>

Online_query.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal" ><Buttonandroid:id="@+id/ButtonVoice"style="?android:attr/buttonStyleSmall"android:layout_width="50dp"android:layout_height="50dp"android:background="@drawable/voice"android:onClick="say" /><AutoCompleteTextViewandroid:id="@+id/seek"android:layout_width="155dp"android:layout_height="wrap_content"android:completionThreshold="1"android:ems="10"android:textColor="#000000" ><requestFocus /></AutoCompleteTextView><Buttonandroid:id="@+id/ButtonGo"android:layout_width="50dp"android:layout_height="50dp"android:background="@drawable/ok" /><Buttonandroid:id="@+id/clearButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/img4"android:textSize="15sp" /></LinearLayout><WebViewandroid:id="@+id/myWebView1"android:layout_width="match_parent"android:layout_height="match_parent" android:focusable="false"/></LinearLayout>

五.增加权限

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.dictionary"android:versionCode="1"android:versionName="1.0" ><uses-sdkandroid:minSdkVersion="8"android:targetSdkVersion="10" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><uses-permission android:name="android.permission.RECORD_AUDIO" /><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /><uses-permission android:name="android.permission.READ_PHONE_STATE" /><applicationandroid:allowBackup="true"android:icon="@drawable/logo"android:label="@string/app_name"android:theme="@style/AppTheme" ><activityandroid:name="com.example.dictionary.HomeActivity"android:label="@string/app_name" ><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activity android:name=".OfflineQuery"></activity><activity android:name=".OnlineQuery"></activity><activity android:name=".MainActivity"></activity><activity android:name=".NoteBook"></activity><activity android:name=".About"></activity><activity android:name=".EditWord"></activity></application></manifest>

电子词典的实现(一)相关推荐

  1. python自己做电子词典_python实现电子词典

    本文实例为大家分享了python实现电子词典的具体代码,供大家参考,具体内容如下 服务端 #!/usr/bin/env python3 from __future__ import unicode_l ...

  2. C++实践参考——OOP版电子词典

    [项目-OOP版电子词典] 做一个简单的电子词典.在文件dictionary.txt中,保存的是英汉对照的一个词典,词汇量近8000个,英文.中文释义与词性间用'\t'隔开. (1)编程序,由用户输入 ...

  3. Python控制台英汉-汉英电子词典

    2019独角兽企业重金招聘Python工程师标准>>> Python控制台英汉-汉英电子词典 By qianghaohao(CodeNutter) 用python实现了下控制台电子词 ...

  4. 实现电子词典_它是一部电子词典,一部翻译机,一部口语机还是一部出游的随身WiFi...

    科技扒爷带你看 有了小爱老师,一定程度上解决了英语学习的问题.它是一部电子词典.一部翻译机,一部口语机.还是一部出游的随身WiFi. 外观上,全白配色,磨砂质感的塑料机身,3.97英寸LCD触摸屏,操 ...

  5. Android Webview实现有道电子词典

    毕业设计android电子词典,先实现的一个小小的demo. 所谓的毕业设计就是用最短的时间学习一门语言,做出一个小的project. activity_main.xml <LinearLayo ...

  6. 手机电子词典_网易有道入局,「智能化」能拯救电子词典这个「老古董」吗?...

    电子产品,向来代表着「新奇」和「进步」.但进步同时也意味着速朽,上一代造物不断被后继者兼并.取代.于是,软盘.小灵通.VCD 等名词一个个从市场上消隐,进入互联网「前浪」们的回忆. 但有个领域似乎独立 ...

  7. 使用Android简单实现有道电子词典

    前言: 毕业设计的内容,仅仅有Java基础.没学过Android. 本着用到什么学什么.花费了10多个晚上完毕毕业设计. 当然,仅仅是简单的实线了电子词典功能,自始至终没有考虑过性能等问题. 本电子词 ...

  8. MATLAB 手把手带你制作第一个APP designer程序(电子词典)

    注:左上角图标的添加方式(老版本和新版本俩种方法)放在文章最后 注此方法针对的为2019版本及之前的版本,比较新版本以增添该功能,直接设置uifigure的Icon属性即可,使用压缩包内文件可将sta ...

  9. 电子词典 C语言实现

    电子词典 做一个简单的电子词典.在文件dictionary.txt中,保存的是英汉对照的一个词典,词汇量近8000个,英文与释义间用'\t'隔开.编程序,将文件中的内容读到两个数组e[]和c[]中,分 ...

  10. 电子英汉词典c语言程序设计报告,英汉电子词典设计报告_设计_C语言_C语言程序设计.doc...

    英汉电子词典设计报告_设计_C语言_C语言程序设计 课程设计 课程名称 :C语言程序课程设计 题目名称 :电子英汉词典 学生学院 :电气信息学院 专业班级 :自动化1101 学 号 :20110102 ...

最新文章

  1. 微信小程序实时获取用户经纬度
  2. 青少年编程竞赛交流群周报(第040周)
  3. MyBatis学习总结(1)——MyBatis快速入门
  4. Xcode5下使用纯代码构建简单的HelloWorld程序
  5. Linux学习——shell编程之变量
  6. 牛客小白月赛6 H 挖沟
  7. mysql 不排序_第08期:有关 MySQL 字符集的注意事项
  8. 根据DbSchema生成代码2
  9. LeetCode 2116. 判断一个括号字符串是否有效(栈)
  10. rust腐蚀怎么单人游戏_腐蚀游戏怎么提高帧数 Rust设置隐藏画质提高FPS教程
  11. ob和mysql兼容吗_OceanBase SQL简介
  12. 2106. [NOIP2015] 斗地主
  13. Java每天学习一点点 09.10.13
  14. linux模板机配置文件,制作Centos 7.4操作系统模板机
  15. mybatis+oracle批量插入报不符合协议和sql未正确结束
  16. 在VC中使用Windows管道技术编程
  17. CentOS安装Nginx 报错“configure: error: the HTTP rewrite module requires the PCRE library”解决办法...
  18. 生产环境apache2整合tomcat动静分离
  19. Onvif协议之服务端开发基本流程
  20. activex控件 java_ActiveX控件不自动安装

热门文章

  1. JVM-整体结构深度解析(2)
  2. 结构-02. 有理数加法(15)
  3. 如何查看多个Office 365 Group的Owner
  4. 7-2 有理数加法 (10 分)
  5. 企业电子邮箱的企业网盘是什么?如何使用?
  6. 那些年,我们一起写过的代码
  7. 计算机表示法是知识表示法么,知识表示方法比较.pdf
  8. [原创]从程序员角度分析安徽电信HTTP劫持的无耻行径 – 之深度分析
  9. 真空本质和对称性破缺
  10. APP的图标测试之震惊!双11快到了,你的app在偷偷更换图标?