2012-06-03 41 views
0

我有這樣一行:我使用Eclipse在Android上進行開發我如何查看日誌?

Log.i("----------",Arrays.toString(Locale.getAvailableLocales())); 

此行給我可用語言的列表我的設備上。 但是,我可以看到它的列表只有在我運行該程序後,我也看到它在一個視圖窗口的底部忘記至少一個因爲意外,但我看到它一秒鐘的綠色。

有沒有什麼辦法看到這個日誌列表陣列後,我運行該程序,也看到它在PC上更好,而不是在設備中,我的意思是像一個messageBox什麼的?我的意思是在它自己的Eclipse中看到它更好。

另一個問題是我在Main.xml設計器中添加了一個按鈕和一個文本框,但我不能拖動它們。我把它們拖到正確的區域,但我不能移動它們,它們被鎖定在現在的位置。有什麼方法可以改變他們在設計師的位置?

這是我的代碼:

package com.testotspeech; 

import java.util.Arrays; 
import java.util.Locale; 

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; 

public class AndroidTestToSpeechActivity extends Activity implements 
     TextToSpeech.OnInitListener { 
    /** Called when the activity is first created. */ 

    private TextToSpeech tts; 
    private Button btnSpeak; 
    private EditText txtText; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     Log.i("----------",Arrays.toString(Locale.getAvailableLocales())); 
     tts = new TextToSpeech(this, this); 

     btnSpeak = (Button) findViewById(R.id.btnSpeak); 

     txtText = (EditText) findViewById(R.id.txtText); 

     // button on click event 
     btnSpeak.setOnClickListener(new View.OnClickListener() { 

      public void onClick(View arg0) { 
       speakOut(); 
      } 

     }); 
    } 

    @Override 
    public void onDestroy() { 
     // Don't forget to shutdown tts! 
     if (tts != null) { 
      tts.stop(); 
      tts.shutdown(); 
     } 
     super.onDestroy(); 
    } 

    public void onInit(int status) { 

     if (status == TextToSpeech.SUCCESS) { 

      int result = tts.setLanguage(Locale.CHINESE); 

      if (result == TextToSpeech.LANG_MISSING_DATA 
        || result == TextToSpeech.LANG_NOT_SUPPORTED) { 
       Log.e("TTS", "This Language is not supported"); 
      } else { 
       btnSpeak.setEnabled(true); 
       speakOut(); 

      } 

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

    } 

    private void speakOut() { 

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

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

感謝。

回答

1

在Eclipse

單擊窗口>顯示視圖>其它> logcat的

+0

LogCat是不錯的視圖選項。 – user1434011

0

另一種查看日誌是從Android的SDK /工具運行ddms.bat。有時候我遇到了Eclipse沒有顯示日誌的問題,而DDMS一直爲我工作。

+0

eclipse有一個DDMS的角度。 – Squonk

相關問題