我想在tabview中顯示文件的內容。文件的每個值都在一個額外的行中。如何在選項卡視圖中顯示文件?
有了這個,我已經能夠讀取行的文件行:
公共類Tab1Activity延伸活動{ 公共無效的onCreate(捆綁savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.infolayout);
String line = "";
TextView text = new TextView(this);
try {
BufferedReader b = new BufferedReader(new FileReader("/sdcard/com.unitnode/debug.txt"));
while ((line = b.readLine()) != null) { // liest zeilenweise aus Datei
text.setGravity(Gravity.CENTER_VERTICAL);
Log.d("zeile", "zeile " + line);
text.setText(line + "\r");
// setContentView(text);
}
b.close();
} catch (IOException e) {
Log.d("fehler", "fehler ");
}
// ViewGroup mContainerView = (ViewGroup) findViewById(tabco);
// mContainerView.addView(text);
}
}
這是相應的佈局的xml:
TabHost的xmlns:機器人= 「http://schemas.android.com/apk/res/android」 android:layout_width =「fill_parent」 android:layout_height =「fill_parent」 android:id =「@ android:id/tabhost」>
<LinearLayout
android:id="@+id/LinearLayout01"
android:orientation="vertical"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
</FrameLayout>
<TextView
android:id="@+id/text1"
android:text="test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
如何顯示在TabView的整個文件?
編輯:問題不在於如何創建制表符。只是如何在一個標籤中顯示文件。選項卡已經存在。但我的問題是,我只能顯示一行。我想顯示文件的所有行。
感謝
可能重複(http://stackoverflow.com/questions/1117641/how-在Android中使用一個tab-widget) – 2014-09-11 11:53:17
請谷歌請 – 2014-09-11 11:53:29
請不要downvote我的問題,因爲我認爲你downvoted它,因爲創建制表符。但這不是我的問題。我的問題的答案來自SME_DEV – user3603935 2014-09-12 12:09:49