AppCompat22.1.0でFragmentにAppComatXXViewが適用されない
この記事の事象は、AppCompat 22.1.1で修正済みです。
バグの事象
22.1.0のAppCompatActivity(旧ActionBarActivity)を適用すると、FragmentのinflateにActivityのLayoutInflaterが適用されない
既に、Future Relaseになってますが、現時点の対応方法として2つあります。
修正方法その1
22.1.0以前の実装を自分で書いてやればいいだけです。
BaseActivityを作っている人は1行で終わります。
BaseActivity
public class BaseActivity extends AppCompatActivity {
@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
// DelegateのcreateView()をreturnするようにする
return getDelegate().createView(parent, name, context, attrs);
}
}
修正方法その2
Issueコメントにあるように、引数のLayoutInflaterではなく、getActivity().getLayoutInflater()を利用します。
HogeFragment
public class HogeFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// getActivity().getLayoutInflater()を使う
return getActivity().getLayoutInflater().inflate(R.layout.fragment_security, null, false);
}
}
Author And Source
この問題について(AppCompat22.1.0でFragmentにAppComatXXViewが適用されない), 我々は、より多くの情報をここで見つけました https://qiita.com/ushi3_jp/items/82f29ec6352165859dd2著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .