私は、動的に生成されたFrameLayoutを反応ネイティブビューに追加しました。 Framelayoutが表示されます。ビューにフラグメントを追加すると、何も表示されません。ここ反応するネイティブのビューを追加するフラグメントが表示されない
は、コードの一部です:
public FrameLayout createViewInstance(ThemedReactContext context) {
Fragment fragment = MapFragment.newInstance(mapKey);
FrameLayout view = new FrameLayout(context);
view.setWillNotDraw(false);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
view.setLayoutParams(lp);
view.setId(View.generateViewId());
view.setBackgroundColor(Color.parseColor("#1FFDDB"));
FragmentActivity activity = MainActivity.getFragmentActivity();
FragmentManager fragmentManager = activity.getSupportFragmentManager();
fragmentManager.beginTransaction().remove(fragment).commit();
fragmentManager.executePendingTransactions();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(0, fragment);
fragmentTransaction.show(fragment);
fragmentTransaction.attach(fragment);
fragmentTransaction.commit();
fragmentManager.executePendingTransactions();
return view;
}
私はそれが表示されているビューにのTextViewを追加する場合:
// add a textfield to the view
TextView textView1 = new TextView(context);
textView1.setText("Android");
textView1.setTextSize(30);
textView1.setGravity(Gravity.CENTER);
view.setVisibility(View.VISIBLE);
view.addView(textView1);
ので断片との問題があります。 フラグメントが表示されない理由を教えてください。
http://stackoverflow.com/questions/34410559/how-do-weget-an-android-fragment-to-show-up-in-react-native – Danieboy
私はそれを説明したように実装しました。/34410559。まだ何も表示されません。 –
私はfragmentTransaction.add(0、fragment)を置き換えます。 fragmentTransaction.add(view.getId()、fragment)を使用します。でも同じ問題(ノーショー) –