Jason Axelrod
Jason Axelrod

Reputation: 7815

Android ActionBar/Toolbar Disappears in my App

So I have an app. It has 3 activities at the moment... I am using intents to launch the activities from one and another

MainActivity > ChallongeLogin > ChallongeEvents

In my MainActivity and my ChallongeLogin, there is a large bar at the top of the app that lists the name of my app. However, when I eventually read the ChallongeEvents, this bar disappears... I don't remember doing anything special to make this bar disappear. Why did it go away?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.testing.testingapp">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity
            android:screenOrientation="portrait"
            android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:screenOrientation="portrait"
            android:name=".ChallongeLogin" />

        <activity
            android:screenOrientation="portrait"
            android:name=".ChallongeEvents" />

    </application>

</manifest>

Upvotes: 3

Views: 4738

Answers (2)

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75798

According to your requirement you must extends AppCompatActivity instead of Activity .

public class ActivityName extends AppCompatActivity {
  // ...
}

AppCompatActivity is from the appcompat-v7 library. Principally, this offers a backport of the action bar. Since the native action bar was added in API Level 11, you do not need AppCompatActivity for that. However, current versions of appcompat-v7 also add a limited backport of the Material Design aesthetic, in terms of the action bar and various widgets. There are pros and cons of using appcompat-v7, well beyond the scope of this specific Stack Overflow answer.

Reference

Activity, AppCompatActivity, FragmentActivity, and ActionBarActivity: When to Use Which?

Upvotes: 3

Viral Patel
Viral Patel

Reputation: 33438

It is called ActionBar/ToolBar.

Extend the AppCompatActivity class instead of plain Activity class in that activity's java class.

Upvotes: 1

Related Questions