Hey guys i have an app with two activities, in the second activity i have an action bar with the title of my app displayed without problem. However in my launcher activity the bar is shown in android studio display but not in the actual app... Any idea whats happening ? Here is my xml :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".Menu_Activity">
<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_weight="0.99"
android:dividerHeight="2px">
</ListView>
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Download content"
android:textColor="#FFFFFF"
android:id="@+id/button"
android:background="@drawable/buttonshape" />
</LinearLayout>
and here is the xml where the bar is displayed :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
/>
<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:divider="#FF000080"
android:dividerHeight="2px">
</ListView>
</LinearLayout>
Im not doing anything concerning the bar in the java files except extending AppCompatActivity in both cases.
Here is the styles file :
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
Thank you for your help.
I am thinking that you somehow want to display a listView with content in your activity that has fails to display the action bar. Well here is what I did for mine. In the main method I extended AppCompactActivity and in the method itself I declared the listView as a variable like
ListView listView;
then after that, in the onCreate method of the main object you just simply connect this to the id of your list usinglistView = (ListView) findViewById(R.id.thelistid)
after that I simply called the adapter that should fill the list with content aslistView.setAdapter(nameOfYourAdapter)
Hope this helps!Possibility 1: If your app extends
Activity
change it toAppCompatActivity
.Possibility 2: Are you sure you don't have different files of different versions named "styles.xml"? Make sure that none of the them have a theme named
AppTheme.NoActionBar
.The device you are running the app will fetch the more adequate theme for its version. If you have a file named
styles.xml(v21)
for example, devices with Lollipop or above will use it.