新しいアクティビティを入力すると、アプリがクラッシュしているようです。今のところ、このアクティビティには、共有設定のスキルをテストしようとしているテキスト編集フィールドしかありません。共有設定ファイルはまだ作成していませんが、アクセスすると自動的に作成されるという印象を受けています。これがlogcatです:
09-18 02:29:30.293: W/ResourceType(428): No package identifier when getting value for resource number 0x0000000a
09-18 02:29:30.303: D/AndroidRuntime(428): Shutting down VM
09-18 02:29:30.315: W/dalvikvm(428): threadid=1: thread exiting with uncaught exception (group=0x40015560)
09-18 02:29:30.334: E/AndroidRuntime(428): FATAL EXCEPTION: main
09-18 02:29:30.334: E/AndroidRuntime(428): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mangodeveloper.mcathomie/com.mangodeveloper.mcathomie.McatActivityPlayOptions}: android.content.res.Resources$NotFoundException: String resource ID #0xa
09-18 02:29:30.334: E/AndroidRuntime(428): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
09-18 02:29:30.334: E/AndroidRuntime(428): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-18 02:29:30.334: E/AndroidRuntime(428): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-18 02:29:30.334: E/AndroidRuntime(428): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-18 02:29:30.334: E/AndroidRuntime(428): at android.os.Handler.dispatchMessage(Handler.java:99)
09-18 02:29:30.334: E/AndroidRuntime(428): at android.os.Looper.loop(Looper.java:123)
09-18 02:29:30.334: E/AndroidRuntime(428): at android.app.ActivityThread.main(ActivityThread.java:3683)
09-18 02:29:30.334: E/AndroidRuntime(428): at java.lang.reflect.Method.invokeNative(Native Method)
09-18 02:29:30.334: E/AndroidRuntime(428): at java.lang.reflect.Method.invoke(Method.java:507)
09-18 02:29:30.334: E/AndroidRuntime(428): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-18 02:29:30.334: E/AndroidRuntime(428): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-18 02:29:30.334: E/AndroidRuntime(428): at dalvik.system.NativeStart.main(Native Method)
09-18 02:29:30.334: E/AndroidRuntime(428): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0xa
09-18 02:29:30.334: E/AndroidRuntime(428): at android.content.res.Resources.getText(Resources.java:201)
09-18 02:29:30.334: E/AndroidRuntime(428): at android.widget.TextView.setText(TextView.java:2857)
09-18 02:29:30.334: E/AndroidRuntime(428): at com.mangodeveloper.mcathomie.McatActivityPlayOptions.onCreate(McatActivityPlayOptions.java:23)
09-18 02:29:30.334: E/AndroidRuntime(428): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-18 02:29:30.334: E/AndroidRuntime(428): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
09-18 02:29:30.334: E/AndroidRuntime(428): ... 11 more
そしてここにコードがあります:
package com.mangodeveloper.mcathomie;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class McatActivityPlayOptions extends Activity {
private EditText QuestionNumberEt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_playoptions);
QuestionNumberEt = (EditText) findViewById(R.id.Etnumberofquestions);
SharedPreferences settings = getSharedPreferences("MYPREFS", 0);
QuestionNumberEt.setText(settings.getInt("MAXROUNDSVALUE", 10));
Button startGameButton = (Button) findViewById(R.id.startgamebutton);
startGameButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent PlayIntent = new Intent (McatActivityPlayOptions.this, McatActivityGame.class);
PlayIntent.putExtra("MAXROUNDS", Integer.parseInt(QuestionNumberEt.getText().toString()));
startActivity(PlayIntent);
}
});
}
@Override
protected void onStop() {
super.onStop();
SharedPreferences settings = getSharedPreferences("MYPREFS", 0);
SharedPreferences.Editor editor = settings.edit();
editor.putInt("MAXROUNDSVALUE", Integer.parseInt(QuestionNumberEt.getText().toString()));
editor.commit();
}
}