-1
アクティビティ間を移動しようとすると、アプリケーションがクラッシュします。ここにコードは です。私は1つのアクティビティから別のアクティビティに行く前に意図を使用していたので、コードが正しいことが分かりました。私のアプリは、簡単な計算機ですが、ユーザが入力したときに秘密のパスワードアプリはあるアクティビティから別のアクティビティに移動する際にエラーが発生する
equal.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
val2 = Integer.parseInt(temp);
sp = getSharedPreferences("passinfo", Context.MODE_PRIVATE);
if(temp.equals(sp.getString("pass",""))){
Intent i = new Intent(MainActivity.this,Privatefolder.class);
startActivity(i);
}
else if(val1 == null || val2 == null){
Toast.makeText(getApplicationContext(),"Error",Toast.LENGTH_SHORT).show();
}else{
if(operator.equals("+")){
result = val1 + val2;
}
if(operator.equals("-")){
result = val1 - val2;
}
if(operator.equals("*")){
result = val1 * val2;
}
if(operator.equals("/")){
result = val1/val2;
}
temp1 = temp1 +" = " +result.toString();
t1.setText(temp1);
temp="";temp1="";
}
}
});
別のアクティビティに計算から行く私は、マニフェストファイルにも登録活動
<activity android:name=".Privatefolder"></activity>
を持って、私はまた、このようなonclickの方法を使用しています。アプリがクラッシュして何かをしなければならないのでしょうか?ユーザーが0〜9の名前のボタンをクリックすると、このメソッドが実行されます。
protected void onClicknumbers(View v){
Button b = (Button) v;
if(temp1.equals("")) {
temp += b.getText();
t2.setText(temp);
}
else{
temp += b.getText().toString();
temp1 += b.getText();
t1.setText(temp1);
}
}
この
は11-04 20:44:22.744 16989-16989/com.dreamfighter.vault E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dreamfighter.vault, PID: 16989
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dreamfighter.vault/com.dreamfighter.vault.Privatefolder}: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2572)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5728)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
at android.support.v7.app.AppCompatDelegateImplV9.setSupportActionBar(AppCompatDelegateImplV9.java:204)
at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:129)
at com.dreamfighter.vault.Privatefolder.onCreate(Privatefolder.java:18)
at android.app.Activity.performCreate(Activity.java:6309)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2519)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2654)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1488)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5728)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
へ
変更ラインはあなたのポストでlogcatからのエラーメッセージを記載してください。 – Barns
あなたが知る必要があることを伝える行:: 'java.lang.IllegalStateException:このアクティビティには、すでにウィンドウデコレーションによってアクションバーが提供されています。あなたのテーマでWindow.FEATURE_SUPPORT_ACTION_BARを要求せず、代わりにツールバーを使用するようにwindowActionBarをfalseに設定してください。 ' – Barns
Windowactionbas falseを設定する方法を教えてください –