0

私は視覚障害者向けのアプリケーションを作成しています。そのために、ユーザーが画面上の任意の場所に触れるたびに音声認識エンジンを起動する必要があります。

私は音声認識装置などを作成しました..しかし、音声認識装置をTouchListenerで動作させることはできません...

TouchListener は、アクティビティをビューとして取得していません。アプリケーションがクラッシュする

完全なコードは次のとおりです。

public class MainActivity extends Activity
{

private static final int REQUEST_CODE = 1234;
private ListView wordsList;
protected Button TextToSpeech;
/**
 * Called with the activity is first created.
 */
@Override
public void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);  getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
super.onCreate(savedInstanceState);
setContentView(R.layout.voice_recog);
Button speakButton = (Button) findViewById(R.id.speakButton);
Context context;
context = this.getApplicationContext();
Intent Inte = new Intent(context, FallDetection.class);
context.startService(Inte);
Intent Inte1 = new Intent(context, SmsSpeaker.class);
context.startService(Inte1);
Toast toast = Toast.makeText(getApplicationContext(), "Fall Detection Started", Toast.LENGTH_LONG);
toast.show();

 wordsList = (ListView) findViewById(R.id.list);
 LinearLayout myScreen = (LinearLayout) findViewById(R.id.myscreen); 
// change LinearLayout to your framelayout if it is not a LinearLayout
//View view =(View) findViewById(R.layout.voice_recog);

//wordsList.setOnTouchListener(new View.OnTouchListener() {
 myScreen.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        Toast toast = Toast.makeText(getApplicationContext(),"Touch recognised",Toast.LENGTH_LONG);
        toast.show();
        startVoiceRecognitionActivity();
    }
}); 

今のところ、タッチを認識するためにリストを使用していますが、ソースが見つからないという例外でアプリケーションをクラッシュさせています

レイアウトxmlファイルは以下の通りです

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/myscreen" 
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="vertical">
4

1 に答える 1