XML
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffb6c1" >
<TextView
android:id="@+id/def"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@android:color/white"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="24dp" />
</RelativeLayout>
</ScrollView>
File.txt
たとえば、次のような文があります。
文=(今日はクレイジーな日です)。
View に出力する LargeText It(?) クレイジーな日です。
クラスを実装しようとしたこのエラーの答えを知りたいのStringBuilder
ですが、Androidで機能させる方法がわかりません。
これは私が行ったすべての変更ですが、まだ成功していません。
package org.health.canser;
public void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
//setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
super.onCreate(savedInstanceState);
setContentView(R.layout.breast);
getFile(breastFile);
}
//my text fiel input section===============================================================================
public String loadTextFile(InputStream inputStream) throws IOException {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
byte[] bytes = new byte[4096];
int len = 0;
while ((len = inputStream.read(bytes)) > 0)
byteStream.write(bytes, 0, len);
//return new String(byteStream.toByteArray(), "UTF8");
return new String(byteStream.toByteArray(), "UTF-8");
}
public void getFile(String fileName)
{
breast= (View) findViewById(R.id.breastDef);
AssetManager assetManager = getAssets();
InputStream inputStream = null;
try {
inputStream = assetManager.open(fileName);
String text = loadTextFile(inputStream);
Log.i("Msg","msg: " + text);
((TextView) breast).setText(text);
} catch (IOException e) {
((TextView) breast).setText("Couldn't load file");
} finally {
if (inputStream != null)
try {
inputStream.close();
} catch (IOException e) {
((TextView) breast).setText("Couldn't close file");
}
}
}
}
出力:
01-07 15:03:53.628: I/Msg(24930): 危険因子: 女性であることに加えて、加齢は乳がんの最も重要な危険因子です。潜在的に修正可能な危険因子には、18 歳以降の体重増加、過体重または肥満 (閉経後の乳がんの場合)、MHT (エストロゲンとプロゲスチンの併用ホルモン療法) の使用、運動不足、およびアルコール消費が含まれます。より高いリスクを予測する医学的所見には、高い乳房組織密度(乳房の脂肪組織に対する腺組織の量のマンモグラフィ測定値)、高い骨ミネラル密度(密度が低い女性は骨粗しょう症のリスクが高い)、生検などがあります。過形成(細胞の過剰増殖)、特に非定型過形成(正常に見えない細胞の過剰増殖)が確認されました。がん治療のための胸部への高線量放射線もリスクを高めます。30歳以降の最初の子供。