I\'ve got some problems with the onClicklistener in the fragment. If I click on the button nothing happens at all. I get neither a message from the onClicklistener in Logcat
The best way to get all views created you should to redefinition the methode :
@Override
public void onActivityCreated(Bundle saved) {
super.onActivityCreated(saved);
input_text = (EditText) InputFragmentView.findViewById(R.id.input_field);
translate_button = (Button) InputFragmentView.findViewById(R.id.translate);
translate_button.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View view)
{
Log.d("Test", "onClickListener ist gestartet");
Toast.makeText(getActivity().getApplicationContext(), "Test", Toast.LENGTH_LONG).show();
saveInString();
}
});
because this methode called after all view have been created. you should read the life cycle of Fragment.