デバイスの SD カードに保存されているデータからゲームのハイスコア テーブルを作成しようとしています。
これが私のものLeaderboardActivity.java
です:
public class LeaderboardActivity extends Activity {
private Leaderboard leaderboard;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_leaderboard);
TableLayout highscoresTable = (TableLayout) findViewById(R.id.highscoresTable);
this.leaderboard = new Leaderboard();
ArrayList<Player> players = leaderboard.getScores();
if(!(players==null))
{
Collections.sort(players);
for(Player p:players)
{
TableRow newRow = new TableRow(this);
TextView name = new TextView(this);
TextView time = new TextView(this);
name.setText(p.getName());
name.setGravity(Gravity.CENTER_VERTICAL);
name.setPadding(15, 0, 15, 0);
time.setText(p.getTime());
time.setGravity(Gravity.CENTER_VERTICAL);
time.setPadding(15, 0, 15, 0);
newRow.addView(name);
newRow.addView(time);
highscoresTable.addView(newRow);
}
setContentView(highscoresTable);
}
else
{
Log.i("DEBUG", "players is equal to null!");
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_leaderboard, menu);
return true;
}
}
ここに私のXMLがありますactivity_leaderboard.xml
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="horizontal" >
<TableLayout
android:id="@+id/highscoresTable"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="15dp" >
<TableRow
android:id="@+id/headerRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|fill_horizontal"
android:showDividers="middle" >
<TextView
android:text="NAME"
android:gravity="center_vertical"
android:padding="15dp">
</TextView>
<TextView
android:gravity="center_horizontal|center_vertical"
android:padding="15dp"
android:text="TIME" />
</TableRow>
<TableRow
android:id="@+id/testRow"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:text="TEST"
android:gravity="center_vertical"
android:paddingLeft="15dp"
android:paddingRight="15dp">
</TextView>
<TextView
android:gravity="center_horizontal|center_vertical"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:text="NOT REAL" />
</TableRow>
</TableLayout>
</LinearLayout>
何らかの理由でリーダーボードを実行すると、RuntimeException
どうすればこれを機能させることができますか?
アップデート
リクエストに応じて、ここに私のログがあります:
03-29 13:45:41.136: E/AndroidRuntime(9894): FATAL EXCEPTION: main
03-29 13:45:41.136: E/AndroidRuntime(9894): java.lang.RuntimeException: Unable to start activity ComponentInfo{*.*.*.*/*.*.*.*.LeaderboardActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x77
03-29 13:45:41.136: E/AndroidRuntime(9894): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-29 13:45:41.136: E/AndroidRuntime(9894): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-29 13:45:41.136: E/AndroidRuntime(9894): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-29 13:45:41.136: E/AndroidRuntime(9894): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-29 13:45:41.136: E/AndroidRuntime(9894): at android.os.Handler.dispatchMessage(Handler.java:99)
03-29 13:45:41.136: E/AndroidRuntime(9894): at android.os.Looper.loop(Looper.java:123)
03-29 13:45:41.136: E/AndroidRuntime(9894): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-29 13:45:41.136: E/AndroidRuntime(9894): at java.lang.reflect.Method.invokeNative(Native Method)
03-29 13:45:41.136: E/AndroidRuntime(9894): at java.lang.reflect.Method.invoke(Method.java:521)
03-29 13:45:41.136: E/AndroidRuntime(9894): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-29 13:45:41.136: E/AndroidRuntime(9894): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-29 13:45:41.136: E/AndroidRuntime(9894): at dalvik.system.NativeStart.main(Native Method)
03-29 13:45:41.136: E/AndroidRuntime(9894): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x77
03-29 13:45:41.136: E/AndroidRuntime(9894): at android.content.res.Resources.getText(Resources.java:201)
03-29 13:45:41.136: E/AndroidRuntime(9894): at android.widget.TextView.setText(TextView.java:2817)
03-29 13:45:41.136: E/AndroidRuntime(9894): at *.*.*.*.LeaderboardActivity.onCreate(LeaderboardActivity.java:44)
03-29 13:45:41.136: E/AndroidRuntime(9894): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-29 13:45:41.136: E/AndroidRuntime(9894): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-29 13:45:41.136: E/AndroidRuntime(9894): ... 11 more