【发布时间】:2012-03-19 03:19:14
【问题描述】:
我已尝试搜索,但找不到问题的答案。我试图简单地显示一个 int 的值。我想将它作为一个 int 传递。这是我的代码。由于某种原因,它没有显示实际数字,而是显示 %d。
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代码:
<?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>
来自 main.xml 的 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>
提前致谢!
【问题讨论】: