1
Im與Butterknife合作,我有一個問題,當我想改變另一個片段時,應用程序失敗。這是我的第一個片段Butterknife和碎片
@Bind(R.id.tilNombre) TextInputLayout tilNombres;
@Bind(R.id.tilApellido) TextInputLayout tilApellido;
@Bind(R.id.tilDocumento) TextInputLayout tilDocumento ;
@Bind(R.id.btnContinuar) Button btnContinuar;
public RegistroFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_registro, container, false);
ButterKnife.bind(this, view);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
app();
}
void app(){
tilNombres.setHint(getResources().getString(R.string.nombres));
tilApellido.setHint(getResources().getString(R.string.apellidos));
tilDocumento.setHint(getResources().getString(R.string.licencia));
events();
}
void events(){
btnContinuar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RegistroTwoFragment registroTwoFragment = new RegistroTwoFragment();
android.support.v4.app.FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.contenedorRegistro, registroTwoFragment).commit();
}
});
}
在該代碼中我沒有任何問題,問題是在接下來的部分
public class RegistroTwoFragment extends Fragment {
@Bind(R.id.tilCorreo) TextInputLayout tilCorreo;
@Bind(R.id.tilClave) TextInputLayout tilClave;
@Bind(R.id.btnRegistrar) TextInputLayout btnRegistrar;
@Bind(R.id.tviRetroceder) TextInputLayout tviRetroceder;
public RegistroTwoFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_registro_two, container, false);
ButterKnife.bind(this,view);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
app();
}
void app(){
tilCorreo.setHint(getResources().getString(R.string.correo));
tilClave.setHint(getResources().getString(R.string.contrasena));
events();
}
void events(){
tviRetroceder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RegistroFragment registroFragment = new RegistroFragment();
android.support.v4.app.FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.contenedorRegistro, registroFragment).commit();
}
});
}
的logcat的說:無法綁定意見的com.example.aato。 ciudadano.fragments.RegistroTwoFragment;有誰知道這個問題?