fragment相关
作者:互联网
Android 设置 Activity 半透明:
color.xml:
#80000000
style.xml:
Manifest中的activity 标签:
android:theme="@style/AppTheme.translucent"
Fragment 响应 back 键:
Fragment中重写OnResume方法,添加如下代码。
@Override
public void onResume() {
super.onResume();
getView().setFocusableInTouchMode(true);
getView().requestFocus();
getView().setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK){
// handle back button
return true;
}
return false;
}
});
}
标签:getView,onResume,return,KeyEvent,fragment,back,Override,相关 来源: https://blog.csdn.net/prince8087/article/details/101291783