0
私は、1つの変数intを次のアクティビティの文字列に渡し、次のアクティビティでその文字列を受け取り、もう一度intを返します。私はパーセンテージを計算し、テキストビューと過去の変数と約1を計算して、空でないかどうかを確認してから、パーセント(例:3/45)* 100)を計算し、テキストビューで表示します。文字列...しかし、私は間違いを何らかの形ですることができますか?あなたがそうのようなif文の後に{}持っている必要があります%を計算し、アンドロイドスタジオtexviewに表示
Bundle bundle = getIntent(). GetExtras();
String aprox1 = bundle.getString ("aprox1");
if (aprox1! = null)
try {
num3 = Integer.parseInt (aprox1);
result = Math.round ((num3/45) * 100);
TextView counter2 = (TextView) findViewById(R.id.textView16);
String abcString2 = Integer.toString (result);
counter2.setText (abcString2);
}
catch (NumberFormatException e) {
}