onClickListener does not work in fragment

前端 未结 5 1072
梦谈多话
梦谈多话 2020-11-28 12:59

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

5条回答
  •  温柔的废话
    2020-11-28 13:40

    change

     return inflater.inflate(R.layout.input_fgmt, container, false);
    

    to

     return InputFragmentView ;
    

    Also change with this:

    translate_button.setOnClickListener(new View.OnClickListener()
    {
        @Override
        public void onClick(View view)
        {
            Log.d("Test", "onClickListener ist gestartet");
            Toast.makeText(getActivity().getApplicationContext(), "Test", Toast.LENGTH_LONG).show();
            saveInString();
    
        }
    });
    

    and import as a import android.view.View;

提交回复
热议问题