2013-12-14 17 views
0

我一直希望有人能夠幫助我完成有關製作一個非常基本的android gui的基本任務。Android應用程序 - 顯示終端視圖

我有一個應用程序,我想打印一些數據通過toString()。我想在控制檯類型的視圖中顯示它,每10秒左右刷新一次。目前我正在打印Log.e命令,但我不確定需要添加哪個控件才能成爲控制檯輸出視圖。

我想我可以只添加一個文本框,並不斷添加新行,但理想情況下控制檯/命令行輸出是我的願望。

感謝您的幫助

回答

0

在Android中沒有什麼像控制檯。您可以像現在使用的那樣使用logcat,也可以使用一些TextView來顯示輸出。

我想你可以在ScrollView使用TextView這與追加新行之前的文字與XML佈局像

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <TextView 
     android:id="@+id/consoleText" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
</ScrollView> 

,然後補充說:

String previousString = textView.getText().toString(); 
String nextString = previousString + "\n" + nextLine; 
textView.setText(nextString); 
相關問題