Action bar displayed on android studio display but not in my actual application

Hi guys, I have an application with two actions, in the second action I have an action bar with the name of my application displayed without problems. However, in my activity, the launch panels are displayed on the Android studio display, but not in the real application ... Any idea what is 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 panel 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> 

I do nothing regarding the bar in java files, with the exception of the AppCompatActivity extension in both cases.

Here is the stylesheet:

 <!-- 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.

0
source share
2 answers

Option 1: If your application extends Activity , change it to AppCompatActivity .

Opportunity 2: Are you sure that you do not have different files of different versions with the name "styles.xml"? Make sure that none of them has a theme named AppTheme.NoActionBar .

The device on which the application is running will receive a more suitable theme for its version. If you have a file called styles.xml(v21) , for example, devices with Lollipop or higher will use it.

+2
source

I think that somehow you want to display a listView with content in your activity that does not display the action bar. Well, that's what I did for my own. In the main method, I extended AppCompactActivity, and in the method itself, I declared listView as a variable of type ListView listView; and then in the onCreate method of the main object, you simply connected this to the id of your list using listView = (ListView) findViewById(R.id.thelistid) after that I just called the adapter, which should fill the list with contents like listView.setAdapter(nameOfYourAdapter) Hope this helps!

0
source

Source: https://habr.com/ru/post/1274098/


All Articles