mkm писал(а):Необходимо сделать так чтобы пользователю отображался большой текст
Используете ScrollBar и TextView
В layout пишете чтонить подобное:
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>
</ScrollView>
</LinearLayout>
В TextView текст можно положить тремя способами:
1) Добавить его в прямо в вышеуказанный код layout
2) Создать элемент String в res/values/strings.xml, поместить в него весь текст, а в layout указать этот String в свойстве android:text у TextView
3) Закинуть текстовый файл в папку assets в проекте. И его содержимое выводить в TextView:
Код: Выделить всё
tv = (TextView) findViewById(R.id.tv);
try {
BufferedReader br = new BufferedReader(new InputStreamReader(
getAssets().open("rules.txt")));
String text = "";
StringBuilder sb = new StringBuilder();
while ((text = br.readLine()) != null) {
sb.append(text);
}
br.close();
tv.setText(sb.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Первый способ самый легкий, третий - самый элегантный )