我是Android的初学者:(我使用文本输入布局,但我无法抓住它们的任何价值!这是我的代码。现在我想要打印价值" usuario& #34;只是为了检查它是否有任何价值。我使用Butterknife btw D:
public class IngresoFragment extends Fragment {
@Bind(R.id.tilUsuario) TextInputLayout mTilUsuario;
@Bind(R.id.tilPassword) TextInputLayout mTilPassword;
@Bind(R.id.btnIngresar) Button btnIngresar;
@Bind(R.id.tviLibre) TextView tviLibre;
public IngresoFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_ingreso, container, false);
ButterKnife.bind(this,view);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
app();
}
void app(){
mTilUsuario.setHint(getResources().getString(R.string.usuario));
mTilPassword.setHint(getResources().getString(R.string.password));
events();
}
void events(){
btnIngresar.setOnClickListener(new View.OnClickListener() {
String usuario = mTilUsuario.getEditText().getText().toString().trim();
String password = mTilPassword.getEditText().getText().toString().trim();
@Override
public void onClick(View v) {
Toast.makeText(getActivity(), usuario, Toast.LENGTH_LONG).show();
}
});
}
答案 0 :(得分:0)
定义为EditText,只需将TextInputLayout变为EditText