あなたはこのようにそれを行うことができます矢印れる ![This is the fragment that holds the calls to the news](https://i.stack.imgur.com/3WIbn.png)
ニュースへの呼び出しを保持している断片である
フラグメントオーバーライドonCreateメソッドこのように
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true); // note this line
}
その後、戻る矢印オーバーライドonOptionsItemSelectedメソッド完了
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch (id) {
case android.R.id.home:
if (getActivity() != null)
getActivity().onBackPressed();
break;
}
return super.onOptionsItemSelected(item);
}
のクリックのために、この
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
((MainActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); // this is your back arrow
}
と最後のようなメソッドをオーバーライドしonActivityCreated!これがあなたの望むものだと願っています..
これは私のためには機能しませんでした。 –