setOnClickListener in fragment

前端 未结 3 1540
梦如初夏
梦如初夏 2021-01-22 06:51

I have simple application which has 1 Edittext and 1 Button.My application get the numbers in the first two Edit text and when the button is pressed the last EditText show the s

3条回答
  •  庸人自扰
    2021-01-22 07:13

    Try it this way:

    Sum = (Button) InputFragmentView.findViewById(R.id.Sum);
    
    Sum.setOnClickListener(this);
    
    return InputFragmentView;
    }
    
    
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.Sum:
                String N1 = Num1.getText().toString();
                int N11 = Integer.parseInt(N1);
    
                String N2 = Num2.getText().toString();
                int N22 = Integer.parseInt(N2);
    
                S = N11 + N22;
    
                Eq.setText("" + S);
                break;
        }
    }
    

    Anyway, post your Logcat output to know which is the problem you are facing

提交回复
热议问题