我有两个片段。当我尝试从第一个更改第二个时,第二个片段中的调试器连接但内容未显示。我尝试添加和替换方法,但都是一样的。第二个内容没有改变。
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;
}
答案 0 :(得分:0)
嗯,我认为你应该把你的代码放在片段的onCreateView部分,而不是放在activityCreated上,我知道在listfrags上使用了activityCreated,就像我的情况一样:D
答案 1 :(得分:0)
尝试将您在onActivityCreated中编写的代码移动到onStart。