2
私は検索しようとしましたが、私の問題に対する答えを見つけることができませんでした。私は単純にintの値を表示しようとしています。私はintとして渡したい。ここに私のコードです。何らかの理由で実際の数字を表示する代わりに%dを表示しています。アンドロイドアプリのintを.xmlに渡す
Javaコード:
package ebike.picture.com;
import android.app.Activity;
import android.os.Bundle;
public class PictureActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String hello = getString(R.string.aaa, 10);
}
}
のstrings.xmlからXMLコード:main.xmlから
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, PictureActivity!</string>
<string name="app_name">Picture</string>
<string name="aaa">hello %d </string>
</resources>
XMLコード:事前に
<?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="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/aaa" />
</LinearLayout>
ありがとう! JavaのFormatter
クラスを使用して