android读取英文,是非常简单的,接口为TextToSpeech.OnInitListener,  OnClickListener ,实现方法便行。package com.smart;import java.util.Locale;import android.app.Activity;import android.content.ComponentName;import android.content.Intent;import android.os.Bundle;import android.speech.tts.TextToSpeech;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.TextView;import android.widget.Toast;public class ReadText extends Activity implements TextToSpeech.OnInitListener,  OnClickListener { private TextToSpeech tts; private TextView textView; private Button return_back; private Button button; @Override public void onCreate(Bundle savedInstanceState) {  super.onCreate(savedInstanceState);  setContentView(R.layout.read);  tts = new TextToSpeech(this, this);  button = (Button) findViewById(R.id.button);  textView = (TextView) findViewById(R.id.textView);  button.setOnClickListener(this);  return_back = (Button) findViewById(R.id.back);  return_back.setOnClickListener(new OnClickListener() {      @Override   public void onClick(View v) {    Intent intent=new Intent();//    intent.setClass(ReadText.this,Main.class);    intent.setComponent(new ComponentName(ReadText.this,Main.class));   }  }); } //实例化 @Override public void onInit(int status) {  if (status == TextToSpeech.SUCCESS) {   int result = tts.setLanguage(Locale.US);   if (result == TextToSpeech.LANG_NOT_SUPPORTED     || result == TextToSpeech.LANG_MISSING_DATA) {    Toast.makeText(this, "Language is not available.",      Toast.LENGTH_LONG).show();   }  } } @Override public void onClick(View v) {  //得到内容,然后进行读取  tts.speak(textView.getText().toString(), TextToSpeech.QUEUE_FLUSH, null);     }}<?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">          <Button  android:id="@+id/button"  android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:text="读取内容"  />      <Button  android:id="@+id/back"  android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:text="返回"  />    <TextView  android:id="@+id/textView"    android:layout_width="fill_parent"  android:layout_height="fill_parent"  android:text="@string/text"    /></LinearLayout>

更多相关文章

  1. android中的spinner动态加载内容
  2. Android下Notification(通知栏)的使用
  3. 图片压缩保存读取操作
  4. Android(安卓)android下的数据持久化和读取数据,保存数据到手机及
  5. 【原创】Android(安卓)4.4前后版本读取图库图片方式的变化
  6. android TextView 容纳不下内容,让字向左滚动的办法
  7. android TextView 容纳不下内容,让字向左滚动的办法
  8. Android(安卓)UI开发第九篇――SlidingDrawer 抽屉效果
  9. 搭建自己的Android浏览器(一)

随机推荐

  1. Android(安卓)ui
  2. Android四大布局及其主要属性
  3. android:theme常用相关属性值
  4. 自定义动画(animation)时set中的各元素效
  5. 关于android:inputType属性的说明
  6. android 系统开机运行指定程序
  7. Android(安卓)属性"@+id"、"@id"、"@andr
  8. android之theme
  9. Android(安卓)相对布局
  10. Android(安卓)中文API合集(4)(102篇)(chm