2 つのフラグメント (両方とも動的に作成) を含むアクティビティがあり、そのうちの 1 つは ListFragment です。アクティビティに onListItemClick ハンドラを実装しました。アイテムがクリックされたら、両方のフラグメントを他のフラグメントに置き換えて、TextView に入力したいと考えています。ただし、フラグメントを置き換えた後、View オブジェクトを取得できないようです。新しい Details フラグメントで TextView を操作する必要があります。null が返されます。関連するコードを次に示します (onListItemSelected は、メイン アクティビティで onListItemClick を処理するハンドラーです)。
@Override
public void onListItemSelected(int index) {
inflateCheckinFragment();
FragmentManager fm = getFragmentManager();
FragmentTransaction fragmentTransaction = fm.beginTransaction();
cif = new checkInFragment();
fragmentTransaction.replace(R.id.action_container, cif, "ACTIONS");
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit()
FragmentTransaction fragmentTransaction2 = fm.beginTransaction();
gdf = new GeolocDetailsFragment();
fragmentTransaction2.replace(R.id.fragment_container, gdf, "DETAILS");
fragmentTransaction2.addToBackStack(null);
fragmentTransaction2.commit();
View gdfView = gdf.getView();
TextView tv = (TextView) gdfView.findViewById(R.id.textPOI);
tv.setText(printPOI(poiList.get(index)));
}