更新时间:2022-12-19 18:54:17
你所面对的是关系到API中的错误22(5.1)SDK。
请参见在其中不显示操作栏的错误的详细信息,以下链接:
你可以现在做什么
希望这有助于。
I have create demo application in Android Studio with two Activity. In First Activity Show Title Bar in preview as well as in emulator but on second Activity does not show Title Bar in Emulator but it display in preview. I have used API 22 in Android Studio. Please help me....thanx in advn
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/BaseTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".DrawingActivity"
android:label="@string/app_name"
android:theme="@style/BaseTheme"
android:screenOrientation="portrait" />
</application>
Theme style file like this....
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
<style name="BaseTheme" parent="AppTheme">
<item name="colorPrimary">@color/action_bar_backgound</item>
</style>
I have also try this... First Activity Work's fine so I have set that in Second Activity as a setContentView(R.layout.activity_main);
MainActivity.java
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void buttonAction(View v) {
Intent intent = new Intent(MainActivity.this, DrawingActivity.class);
startActivity(intent);
}
}
DrawActivity.java
public class DrawingActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
What you are facing is a bug related to the API 22(5.1) SDK.
Kindly refer the following links for the details on the bug in which the Action Bar is not displayed:
What you can do for now
Hope this helps.