X
xAdorasx
Neues Mitglied
- 0
Hi Leute, ich habe heute mit Hilfe des Buches Android-Apps entwickeln von Uwe Post meine erste Android-App gecodet. Doch jedesmal wenn ich sie starte, crasht sie nach ungefähr 5 Sekunden.
Hier der Code:
Und hier der XML-Code:
Ich hoffe ihr könnt mir helfen, ich hab wirklich keine Idee, wo der Fehler liegt!
Hier der Code:
Code:
package de.example.adorassprachausgabe;
import java.util.Locale;
import android.os.Bundle;
import android.app.Activity;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.view.View;
public class Sprachausgabe extends Activity implements OnInitListener{
private TextToSpeech tts;
/**Called when the activity is first created. */
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tts = new TextToSpeech(this,this);
}
public void onInit(int arg0) {
tts.setLanguage(Locale.GERMAN);
Button sprich = (Button) findViewById(R.id.button1);
sprich.setOnClickListener((OnClickListener) this);
}
public void onClick(View V){
EditText et = (EditText) findViewById(R.id.editText1);
tts.speak(et.getText().toString(), TextToSpeech.QUEUE_FLUSH, null);
}
}
Und hier der XML-Code:
Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="@drawable/gbackground" >
<Button
android:id="@+id/button1"
android:layout_width="68dp"
android:layout_height="wrap_content"
android:text="@string/sag_es" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="216dp"
android:ems="10"
android:inputType="textNoSuggestions"
android:text="@string/beschriftung"
android:textColor="@android:color/white"
android:textSize="25dp" >
<requestFocus />
</EditText>
</LinearLayout>
Ich hoffe ihr könnt mir helfen, ich hab wirklich keine Idee, wo der Fehler liegt!