我已經寫了代碼,菜單的Android中,但它現在會顯示在我的活動了,這裏是我的代碼菜單沒有出現在活動 - 安卓
我只顯示我在這裏的相關代碼,
的Manifest.xml
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppBaseTheme" >
MainActivity.Java
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
switch (item.getItemId()) {
// Some action here
}
}
}
main.xml中
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.androidex1.MainActivity" >
<item android:id="@+id/item1"
android:title="one" />
<item android:id="@+id/item2"
android:title="two" />
<item android:id="@+id/item3"
android:title="three" />
<item android:id="@+id/item4"
android:title="four" />
</menu>
步驟
受審Menu Items are not showing on Action Bar
結果:
嘗試,但仍然菜單的沒有出現
Android options menu not displaying
結果:
菜單仍然沒有出現。
結果:
決不添加該屬性。
Option Menu does not appear in Android
結果:
super.onCreateOptionsMenu(menu); is also added in the code but still the menu's don't appear.
我的問題 我想看到的僅僅是菜單不動作條,可能是什麼問題呢?我沒有收到任何錯誤,主要問題是我無法看到菜單本身。
您使用哪個IDE? – Dario
@Dario Eclipse IDE。 –
好的,我建議使用Android Studio! 你看到我的帖子嗎?我編輯它... – Dario