我想在操作欄上添加過濾器圖標,我添加了一個名爲filer.xml的菜單文件,然後我在該活動的java文件中填充了菜單,但沒有用處,我在該頁面的xml佈局中看不到我的圖標。在android中的操作欄圖標
filter.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=".travels">
<!-- "Mark Favorite", should appear as action button if possible -->
<item
android:id="@+id/action_filter"
android:icon="@drawable/ic_sort_black_24dp"
android:title="@string/bus_filter"
app:showAsAction="always"/>
</menu>
travels.java
public class travels extends AppCompatActivity implements View.OnClickListener {
// private int mYear, mMonth, mDay, mHour, mMinute;
EditText From_edittext, To_Editext, departure_date_edtxt, return_date_edtxt, time1_edtxt, time2_edtxt;
private int mYear, mMonth, mDay, mHour, mMinute;
Button continue_btn;
Switch switchbtn;
private static final LatLngBounds BOUNDS_MOUNTAIN_VIEW = new LatLngBounds(
new LatLng(37.398160, -122.180831), new LatLng(37.430610, -121.972090));
private static final int PLACE_PICKER_REQUEST1 = 1;
private static final int PLACE_PICKER_REQUEST2 = 2;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_journey);
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.filter,menu);
return super.onCreateOptionsMenu(menu);
/*MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.filter, menu);
return true;*/
}
}
添加一些代碼?那麼可以找出問題呢? – Keerthivasan
什麼是他們向我們展示您的主題活動以及您在哪裏充氣該菜單佈局 –
您應該在此處提供代碼。 –