Removing actionBar crashes my app (It says Unfortunately, app has stopped)












0















I'm new to app dev and have searched for a solution to this problem to no avail. I'm creating an app for that incorporates webview and I'm trying to remove the action bar I've tried using actionBar.hide(); and actionBar.setDisplayShowTitleEnabled(false);. I even tried actionBar.setHideOnContentScrollEnabled(true);. What it does is open the app window, then the screen goes black, the app closes and [Unfortunately, app has stopped] pops up.



here's my code
`



import android.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

public class MainActivity extends AppCompatActivity {


WebView webA;
ProgressBar progressBar;

private WebView myWebView;

@Override
public void onBackPressed() {
if (webA.canGoBack()) {
webA.goBack();
}
else {
finish();
}
}

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

ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);//hide title


webA = (WebView)findViewById(R.id.webA);
webA.setWebViewClient(new WebViewClient()); // This ensures that it's opened in the webView not default browser
webA.loadUrl("https://www.fiander.me");

// Progress bar
progressBar = findViewById(R.id.progressBar);
progressBar.setMax(100);
// WebView
WebSettings webSettings = webA.getSettings();
webSettings.setJavaScriptEnabled(true);
webA.setWebChromeClient(new WebChromeClient(){


`










share|improve this question

























  • I found a way to fix it. What I did was:

    – Orange Uncle
    Nov 13 '18 at 15:50
















0















I'm new to app dev and have searched for a solution to this problem to no avail. I'm creating an app for that incorporates webview and I'm trying to remove the action bar I've tried using actionBar.hide(); and actionBar.setDisplayShowTitleEnabled(false);. I even tried actionBar.setHideOnContentScrollEnabled(true);. What it does is open the app window, then the screen goes black, the app closes and [Unfortunately, app has stopped] pops up.



here's my code
`



import android.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

public class MainActivity extends AppCompatActivity {


WebView webA;
ProgressBar progressBar;

private WebView myWebView;

@Override
public void onBackPressed() {
if (webA.canGoBack()) {
webA.goBack();
}
else {
finish();
}
}

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

ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);//hide title


webA = (WebView)findViewById(R.id.webA);
webA.setWebViewClient(new WebViewClient()); // This ensures that it's opened in the webView not default browser
webA.loadUrl("https://www.fiander.me");

// Progress bar
progressBar = findViewById(R.id.progressBar);
progressBar.setMax(100);
// WebView
WebSettings webSettings = webA.getSettings();
webSettings.setJavaScriptEnabled(true);
webA.setWebChromeClient(new WebChromeClient(){


`










share|improve this question

























  • I found a way to fix it. What I did was:

    – Orange Uncle
    Nov 13 '18 at 15:50














0












0








0








I'm new to app dev and have searched for a solution to this problem to no avail. I'm creating an app for that incorporates webview and I'm trying to remove the action bar I've tried using actionBar.hide(); and actionBar.setDisplayShowTitleEnabled(false);. I even tried actionBar.setHideOnContentScrollEnabled(true);. What it does is open the app window, then the screen goes black, the app closes and [Unfortunately, app has stopped] pops up.



here's my code
`



import android.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

public class MainActivity extends AppCompatActivity {


WebView webA;
ProgressBar progressBar;

private WebView myWebView;

@Override
public void onBackPressed() {
if (webA.canGoBack()) {
webA.goBack();
}
else {
finish();
}
}

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

ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);//hide title


webA = (WebView)findViewById(R.id.webA);
webA.setWebViewClient(new WebViewClient()); // This ensures that it's opened in the webView not default browser
webA.loadUrl("https://www.fiander.me");

// Progress bar
progressBar = findViewById(R.id.progressBar);
progressBar.setMax(100);
// WebView
WebSettings webSettings = webA.getSettings();
webSettings.setJavaScriptEnabled(true);
webA.setWebChromeClient(new WebChromeClient(){


`










share|improve this question
















I'm new to app dev and have searched for a solution to this problem to no avail. I'm creating an app for that incorporates webview and I'm trying to remove the action bar I've tried using actionBar.hide(); and actionBar.setDisplayShowTitleEnabled(false);. I even tried actionBar.setHideOnContentScrollEnabled(true);. What it does is open the app window, then the screen goes black, the app closes and [Unfortunately, app has stopped] pops up.



here's my code
`



import android.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;

public class MainActivity extends AppCompatActivity {


WebView webA;
ProgressBar progressBar;

private WebView myWebView;

@Override
public void onBackPressed() {
if (webA.canGoBack()) {
webA.goBack();
}
else {
finish();
}
}

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

ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);//hide title


webA = (WebView)findViewById(R.id.webA);
webA.setWebViewClient(new WebViewClient()); // This ensures that it's opened in the webView not default browser
webA.loadUrl("https://www.fiander.me");

// Progress bar
progressBar = findViewById(R.id.progressBar);
progressBar.setMax(100);
// WebView
WebSettings webSettings = webA.getSettings();
webSettings.setJavaScriptEnabled(true);
webA.setWebChromeClient(new WebChromeClient(){


`







android android-layout android-studio-3.0






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 15:24









Flimzy

37.8k96497




37.8k96497










asked Nov 13 '18 at 15:24









Orange UncleOrange Uncle

12




12













  • I found a way to fix it. What I did was:

    – Orange Uncle
    Nov 13 '18 at 15:50



















  • I found a way to fix it. What I did was:

    – Orange Uncle
    Nov 13 '18 at 15:50

















I found a way to fix it. What I did was:

– Orange Uncle
Nov 13 '18 at 15:50





I found a way to fix it. What I did was:

– Orange Uncle
Nov 13 '18 at 15:50












2 Answers
2






active

oldest

votes


















1














In your manifest AndroidManifest.xml you define your app's theme, something like:



android:theme="@style/AppTheme"


and this theme is defined in styles.xml, something like:



<style name="AppTheme" parent="Theme.AppCompat.Light.LightActionBar">


change it to:



<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">


so there is no ActionBar in your app

and you can remove this code:



ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);//hide title


from onCreate()






share|improve this answer
























  • I tried it from manifest. It didn't work. It finally worked when i changed it from the style.xml

    – Orange Uncle
    Nov 13 '18 at 15:55













  • @OrangeUncle my answer says change the styles.xml not the manifest

    – forpas
    Nov 13 '18 at 16:03



















0














I found a way to fix it. What I did was:



In the projects tab I went into -- res > values > styles.xml.



then changed the parent name to Theme.AppCompat.Light.NoActionBar
like so:



<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284219%2fremoving-actionbar-crashes-my-app-it-says-unfortunately-app-has-stopped%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    In your manifest AndroidManifest.xml you define your app's theme, something like:



    android:theme="@style/AppTheme"


    and this theme is defined in styles.xml, something like:



    <style name="AppTheme" parent="Theme.AppCompat.Light.LightActionBar">


    change it to:



    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">


    so there is no ActionBar in your app

    and you can remove this code:



    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);//hide title


    from onCreate()






    share|improve this answer
























    • I tried it from manifest. It didn't work. It finally worked when i changed it from the style.xml

      – Orange Uncle
      Nov 13 '18 at 15:55













    • @OrangeUncle my answer says change the styles.xml not the manifest

      – forpas
      Nov 13 '18 at 16:03
















    1














    In your manifest AndroidManifest.xml you define your app's theme, something like:



    android:theme="@style/AppTheme"


    and this theme is defined in styles.xml, something like:



    <style name="AppTheme" parent="Theme.AppCompat.Light.LightActionBar">


    change it to:



    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">


    so there is no ActionBar in your app

    and you can remove this code:



    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);//hide title


    from onCreate()






    share|improve this answer
























    • I tried it from manifest. It didn't work. It finally worked when i changed it from the style.xml

      – Orange Uncle
      Nov 13 '18 at 15:55













    • @OrangeUncle my answer says change the styles.xml not the manifest

      – forpas
      Nov 13 '18 at 16:03














    1












    1








    1







    In your manifest AndroidManifest.xml you define your app's theme, something like:



    android:theme="@style/AppTheme"


    and this theme is defined in styles.xml, something like:



    <style name="AppTheme" parent="Theme.AppCompat.Light.LightActionBar">


    change it to:



    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">


    so there is no ActionBar in your app

    and you can remove this code:



    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);//hide title


    from onCreate()






    share|improve this answer













    In your manifest AndroidManifest.xml you define your app's theme, something like:



    android:theme="@style/AppTheme"


    and this theme is defined in styles.xml, something like:



    <style name="AppTheme" parent="Theme.AppCompat.Light.LightActionBar">


    change it to:



    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">


    so there is no ActionBar in your app

    and you can remove this code:



    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);//hide title


    from onCreate()







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 13 '18 at 15:29









    forpasforpas

    10.3k1421




    10.3k1421













    • I tried it from manifest. It didn't work. It finally worked when i changed it from the style.xml

      – Orange Uncle
      Nov 13 '18 at 15:55













    • @OrangeUncle my answer says change the styles.xml not the manifest

      – forpas
      Nov 13 '18 at 16:03



















    • I tried it from manifest. It didn't work. It finally worked when i changed it from the style.xml

      – Orange Uncle
      Nov 13 '18 at 15:55













    • @OrangeUncle my answer says change the styles.xml not the manifest

      – forpas
      Nov 13 '18 at 16:03

















    I tried it from manifest. It didn't work. It finally worked when i changed it from the style.xml

    – Orange Uncle
    Nov 13 '18 at 15:55







    I tried it from manifest. It didn't work. It finally worked when i changed it from the style.xml

    – Orange Uncle
    Nov 13 '18 at 15:55















    @OrangeUncle my answer says change the styles.xml not the manifest

    – forpas
    Nov 13 '18 at 16:03





    @OrangeUncle my answer says change the styles.xml not the manifest

    – forpas
    Nov 13 '18 at 16:03













    0














    I found a way to fix it. What I did was:



    In the projects tab I went into -- res > values > styles.xml.



    then changed the parent name to Theme.AppCompat.Light.NoActionBar
    like so:



    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>





    share|improve this answer




























      0














      I found a way to fix it. What I did was:



      In the projects tab I went into -- res > values > styles.xml.



      then changed the parent name to Theme.AppCompat.Light.NoActionBar
      like so:



      <!-- Base application theme. -->
      <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
      <!-- Customize your theme here. -->
      <item name="colorPrimary">@color/colorPrimary</item>
      <item name="colorPrimaryDark">@color/colorPrimaryDark</item>





      share|improve this answer


























        0












        0








        0







        I found a way to fix it. What I did was:



        In the projects tab I went into -- res > values > styles.xml.



        then changed the parent name to Theme.AppCompat.Light.NoActionBar
        like so:



        <!-- Base application theme. -->
        <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>





        share|improve this answer













        I found a way to fix it. What I did was:



        In the projects tab I went into -- res > values > styles.xml.



        then changed the parent name to Theme.AppCompat.Light.NoActionBar
        like so:



        <!-- Base application theme. -->
        <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 15:54









        Orange UncleOrange Uncle

        12




        12






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53284219%2fremoving-actionbar-crashes-my-app-it-says-unfortunately-app-has-stopped%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python