Android无法打开keycharmap文件

时间:2011-12-21 03:26:29

标签: android android-layout android-intent android-fragments

我是Android Developement的新手。   我正在创建简单的文本到语音语音应用程序,这里我得到错误。我在下面提到过。可以帮助任何人......

03-20 11:49:30.460  24666-24666/com.example.test.app W/KeyCharacterMap﹕ Can't open keycharmap file
03-20 11:49:30.460  24666-24666/com.example.test.app W/KeyCharacterMap﹕ Error loading keycharmap file
03-20 11:49:30.460  24666-24666/com.example.test.app W/KeyCharacterMap﹕ Using default keymap 

代码:

package com.example.test.app;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.app.Activity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;

import java.util.Locale;

public class MainActivity extends Activity implements TextToSpeech.OnInitListener{

    private TextToSpeech speech;
    private ImageButton speak;
    private EditText comments;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        speech = new TextToSpeech(this, this);

        speak = (ImageButton) findViewById(R.id.imageButton1);

        comments = (EditText) findViewById(R.id.editText1);

        speak.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                speak();
                // onKeyUp(keyCode, event);
                //onKeyUp (int keyCode, KeyEvent event);

            }

        });
    }

      public 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;
      }
    @Override
    public void onInit(int status)

    {

        if (status == TextToSpeech.SUCCESS)

        {

            int result = speech.setLanguage(Locale.getDefault());

            if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                Log.e("TTS", "This language is not supported");
            }
            else

            {
                speak.setEnabled(true);
                speak();
            }

        }

        else

        {
            Log.e("TTS", "Initilization Failed!");
        }

    }

    private void speak()
    {

        String text = comments.getText().toString();

        speech.speak(text, TextToSpeech.QUEUE_FLUSH, null);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

}

0 个答案:

没有答案