I would like to ask you guys, I have defined the following code in a certain Fragment:
DetailActivity = (DetailActivity) getActivity();
LayoutInflater factorys = LayoutInflater.from(DetailActivity);
View view= factorys.inflate(R.layout.activity_detail, null);
killswitch = (CheckBox) view.findViewById(R.id.killswitch);
inputTv = (EditText) root.findViewById(R.id.inputTv);
and the two CheckBox and EditText have been defined and monitored in DetailActivity and View
killswitch = (CheckBox) findViewById(R.id.killswitch);
inputTv = (EditText) findViewById(R.id.inputTv);
killswitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
// TODO Auto-generated method stub
if(isChecked){
inputTv.setText("1");
Log.e("kill:", "onCheckedChanged: " );
}else{
inputTv.setText("0");
Log.e("kill:", "onCheckedChanged: ");
}
}
});
in DetailActivity, getting the status and inputTV value of killswitch is completely normal
however, using the first code posted in a Fragment, you can only get the first two values. For example, the default CheckBox in my view is false and inputTv is 1 (the initial value has been tried). However, after the CheckBox is dynamically clicked, the acquisition inputTv and CheckBox in Fragment are still the initial values.
dynamic assignment for the latest clicks in DetailActivity. (Fragment is called through other buttons)