0

I'm trying to display log value on the console, when I click on a Button inside a fragment. I don't know why but nothing happens when I click.

I tried by all possible ways (onClick directly on the layout, setOnClickListener extends OnClickListener, setting "clickable"=true).

Thank you for the help!

public class displayFacesFragment extends Fragment  {

    public static final String TITLE = "Faces";
    public String selectedPeriod;
    public Set<String>  idFurnitures;
    Button button75;


    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        View inputFragmentView = inflater.inflate(R.layout.fragment_display_faces, container, false);

        button75 =(Button) inputFragmentView.findViewById(R.id.button75);


        button75.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.d("Test", "onClickListener");
            }
        });



        return inputFragmentView;
    }


<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/fragment_faces"
    tools:context="com.example.haddad.managemyrounds.controller.fragment.displayFacesFragment">

    <!-- TODO: Update blank fragment layout -->

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="@string/hello_blank_fragment" />

    <Button
        android:id="@+id/button75"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

</FrameLayout>
Brian
  • 7,955
  • 16
  • 66
  • 107
  • Can you try adding clickable true to your textview and button - https://stackoverflow.com/questions/16377593/how-to-disable-behind-view-click-event-framelayout – Praveen Pandey Dec 13 '17 at 22:26
  • Could you try replacing the `Log` with a `Toast`? Maybe you aren't reading the logs correctly. – n_r Dec 15 '17 at 16:19

0 Answers0