3

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>
Viral Patel
  • 32,418
  • 18
  • 82
  • 110
Jason Axelrod
  • 7,155
  • 10
  • 50
  • 78

2 Answers2

3

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?

Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
1

It is called ActionBar/ToolBar.

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

Viral Patel
  • 32,418
  • 18
  • 82
  • 110