0
내 도구 모음 버튼이 조각으로 표시되어 있지 않습니다. 시도했습니다. setHasOptionsMenu (true);. 탐색 서랍 항목을 클릭하면 각 조각에 대해 새 조각을로드합니다. 다른 작업 표시 줄 단추 (알림 또는 저장)를 표시하려고합니다. 다음은 내 코드입니다. 미리 감사드립니다. 다음작업 표시 줄 단추가 단편에 표시되지 않습니다.
내 조각 코드 :
public class Company1 extends Fragment {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_company_profile,container, false);
init(view);
btnAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showAddDialog();
}
});
return view;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.company_profile, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.notification:
break;
}
return super.onOptionsItemSelected(item);
}
}
이것은 (이 탐색 서랍에있는 모든 조각에 대한 동일) company_profile.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" >
<item
android:id="@+id/notification"
android:icon="@drawable/ic_action_notification"
android:title="@string/mnuNotificationText"
app:showAsAction="always"/>
</menu>
어떤 조각에 전혀 나타나지 않거나 일부 경우에만 (업데이트되지 않는 등)? – Shaishav
탐색 서랍이있는 모든 조각에 없습니다. – Harshad07