0
當我說Hello World時,如何讓該程序顯示簡單的Hello World消息?我想把這個程序變成一個語音識別應用程序,它顯示我在Android 2.1或更高版本的手機屏幕上顯示的內容。你好,世界。語音識別
到目前爲止,這是我所:
// **** SpeechRecognition.java *****
package com.SpeechRecognition.CMPE4373;
import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
import android.os.Handler;
import android.speech.*;
import android.inputmethodservice.*;
public class SpeechRecognition extends Activity {
/* Declaring variables */
private static final String TAG = "VoiceRecognition";
private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;
private ListView mList;
private Handler mHandler;
private Spinner mSupportedLanguageView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mHandler = new Handler();
}
}
<!-- layout/main.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" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
<!-- AndroidManifest.xml -->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.SpeechRecognition.CMPE4373"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application
android:icon="@drawable/ic_launcher2"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".SpeechRecognition" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
你知道我需要創建一個顯示「Hello World文本字段什麼行代碼「當我用上面相同的代碼在麥克風上講話時? – user1046106