在预览动作栏是可见的,但在AVD中没有,我不知道为什么。
如何在Device中显示Actionbar?
我尝试了一些更改,例如删除Apptheme.NoActionBar ......但是没有用。
任何想法?这是我的代码:
清单
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".ListActivity"
android:label="@string/title_activity_list"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".FahrzeugActivity"
android:label="@string/title_activity_fahrzeug"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".WebActivity"
android:label="@string/title_activity_web"
android:theme="@style/AppTheme.NoActionBar" ></activity>
</application>
</manifest>
activity.xml和Activity.class
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_fahrzeug"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="ibas.locatixteamviewer.FahrzeugActivity">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/fahrzeug_webView" />
</RelativeLayout>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fahrzeug);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
webView = (WebView) findViewById(R.id.fahrzeug_webView);
webView.getSettings().setJavaScriptEnabled(true); //Javascript erlauben bzw. aktivieren
webView.setWebViewClient(new WebViewClient()); //Diese Zeile, damit wir unsere App verwenden für die Webiste und nicht irgendein Browser geöffnet wird.
webView.loadUrl("Link..."); //?m=1&u=Gast&p=Gast
//webView.loadData("<html> <body> <h1> Hallo habibi </h1> <p> Das ist meine Testpage!!! </p> </body> </html>" , "text/html", "UTF-8"); //eigene Website anzeiogen durch HTML Code
webView.canGoBack();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_fahrzeug, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
//Handle item selection
switch (item.getItemId()) {
case R.id.map_tab:
Intent intent = new Intent(this, MapsActivity.class);
startActivity(intent);
return true;
case R.id.list_tab:
Intent intent2 = new Intent(this, ListActivity.class);
startActivity(intent2);
return true;
case R.id.web_tab:
Intent intent3 = new Intent(this, WebActivity.class);
startActivity(intent3);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
我该怎么办?
非常感谢!