0

私は2つのフラグメントを持っています。最初のフラグメントから 2 番目のフラグメントを変更しようとすると、デバッガーは 2 番目のフラグメントに参加しますが、コンテンツは表示されません。メソッドの追加と置換を試みますが、すべて同じです。2 番目の内容は変更されません。

FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

        RepairViewFragment fragment = new RepairViewFragment();
        fragmentTransaction.add(R.id.detailFragment, fragment);
        fragmentTransaction.commit();

ありがとう。

これはのコードですRepairViewFragment

public class RepairViewFragment extends Fragment implements OnClickListener {

//  private final static int REQUEST_ENABLE_BT = 1;
//  private final static int REQUEST_BT_SETTINGS = 2;

ProgressDialog myProgressDialog = null;
BluetoothAdapter mBluetoothAdapter = null;

ArrayList<MachineBT> Machines = new ArrayList<MachineBT>();

String BluetoothDevices = "";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);




}

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);


    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    Button btn_cl = (Button)getView().findViewById(R.id.btn_client_automat);
    btn_cl.setOnClickListener(this);

    Button btn_own = (Button)getView().findViewById(R.id.btn_own_automat);
    btn_own.setOnClickListener(this);

    ImageButton img_back = (ImageButton)getView().findViewById(R.id.img_back);
    img_back.setOnClickListener(this);



}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.repair_layout, container, false);
    return view;
}
4

2 に答える 2

0

うーん、コードは、activityCreatedではなく、フラグメントのonCreateView部分に配置する必要があると思います。私の場合のように、activityCreatedはlistfragsで使用されます。

于 2012-09-27T06:47:24.787 に答える
0

onActivityCreated 内に記述したコードを onStart に移動してみてください。

于 2012-09-27T07:19:11.830 に答える