-5

Im new to Android Studios. Earlier I had all my buttons on the home scree working fine, but when I tried to run it there it is crashing.

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

import com.start.layout.*;


public class MainActivity extends ActionBarActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button startbutton = (Button) findViewById(R.id.StartButton);
    startbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, Start.class));
        }
    });
    Button historybutton = (Button) findViewById(R.id.HistoryButton);
    historybutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, History.class));
        }
    });
    Button settingsbutton = (Button) findViewById(R.id.SettingsButton);
    settingsbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, Settings.class));
        }
    });
}

Error :

FATAL EXCEPTION: main Process: com.example.mf124.pricetackbenj, PID: 2619 java.lang.RuntimeException: Unable to start activity ComponentInfo java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead

Thats the code for my buttons. Its the start button that is crashing, the other two are working fine. Anyone see a reason why this wouldn't be working?

The errors are:

FATAL EXCEPTION: main Process: com.example.mf124.pricetackbenj, PID: 1994 java.lang.RuntimeException: Unable to start activity ComponentInfo

This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.

Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.

Shahzad Barkati
  • 2,532
  • 6
  • 25
  • 33
Bjohnston
  • 35
  • 1
  • 7
  • post your error also – Hitesh Bhalala Dec 09 '15 at 05:54
  • FATAL EXCEPTION: main Process: com.example.mf124.pricetackbenj, PID: 2619 java.lang.RuntimeException: Unable to start activity ComponentInfo – Bjohnston Dec 09 '15 at 05:54
  • java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead. – Bjohnston Dec 09 '15 at 05:55

1 Answers1

0

include this line in your style.

<item name="windowActionBar">false</item> 

I hope it will work.

Here is your style folder

enter image description here

Hitesh Bhalala
  • 2,872
  • 23
  • 40