how to add java code in fragment activity in android

Tablayout is properly working with single textview which is displayed in each tab, i add calculator to one of tab named Tabfragment2, calculator xml in Tabfragment2 has no error while java code of calculator in fragment2.java i face error in findViewById all of them

public class TabFragment2 extends Fragment {
Activity referenceActivity;

Button btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btndiv, btnadd, btnsub, btnmul, btnzero, btndot, btnclear, btnequal ;
TextView textview;
float ValueOne, ValueTwo;
boolean Addition, Subtract, Multiplication, Division;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.tab_fragment_2, container, false);
    referenceActivity = getActivity();

    btnzero = (Button) findViewById(R.id.btnzero);
    btn1 = (Button) findViewById(R.id.btn1);
    btn2 = (Button) findViewById(R.id.btn2);
    btn3 = (Button) findViewById(R.id.btn3);
    btn4 = (Button) findViewById(R.id.btn4);
    btn5 = (Button) findViewById(R.id.btn5);
    btn6 = (Button) findViewById(R.id.btn6);
    btn7 = (Button) findViewById(R.id.btn7);
    btn8 = (Button) findViewById(R.id.btn8);
    btn9 = (Button) findViewById(R.id.btn9);
    btnadd = (Button) findViewById(R.id.btnadd);
    btndiv = (Button) findViewById(R.id.btndiv);
    btnsub = (Button) findViewById(R.id.btnsub);
    btnmul = (Button) findViewById(R.id.btnmul);
    btndot = (Button) findViewById(R.id.btndot);
    btnclear = (Button) findViewById(R.id.btnclear);
    btnequal = (Button) findViewById(R.id.btnequal);
    textview = (TextView) findViewById(R.id.textview);

    btn1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText(textview.getText() + "1");
        }
    });
    btn2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText(textview.getText() + "2");
        }
    });
    btn3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText(textview.getText() + "3");
        }
    });
    btn4.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText(textview.getText() + "4");
        }
    });
    btn5.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText(textview.getText() + "5");
        }
    });
    btn6.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText(textview.getText() + "6");
        }
    });
    btn7.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText(textview.getText() + "7");
        }
    });
    btn8.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText(textview.getText() + "8");
        }
    });
    btn9.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText(textview.getText() + "9");
        }
    });
    btnzero.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText(textview.getText() + "0");
        }
    });
    btndiv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText(textview.getText() + "/");
        }
    });
    btnadd.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (textview == null) {
                textview.setText("");
            } else {
                ValueOne = Float.parseFloat(textview.getText() + "");
                Addition = true;
                textview.setText(null);
            }
        }
    });
    btnsub.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (textview == null) {
                textview.setText("");
            } else {
                ValueOne = Float.parseFloat(textview.getText() + "");
                Subtract = true;
                textview.setText(null);
            }
        }
    });
    btndiv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (textview == null) {
                textview.setText("");
            } else {
                ValueOne = Float.parseFloat(textview.getText() + "");
                Division=true;
                textview.setText(null);
            }
        }
    });
    btnmul.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (textview == null) {
                textview.setText("");
            } else {
                ValueOne = Float.parseFloat(textview.getText() + "");
                Multiplication = true;
                textview.setText(null);
            }
        }
    });
    btnequal.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ValueTwo = Float.parseFloat(textview.getText() + "");
            if (Addition == true) {
                textview.setText(ValueOne + ValueTwo + "");
                Addition = false;
            }
            if (Subtract == true) {
                textview.setText(ValueOne - ValueTwo + "");
                Subtract = false;
            }
            if (Multiplication == true) {
                textview.setText(ValueOne * ValueTwo + "");
                Multiplication = false;
            }
            if (Division == true) {
                textview.setText(ValueOne / ValueTwo + "");
                Division = false;
            }
        }
    });
    btnclear.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText("");
        }
    });
    btndot.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            textview.setText(textview.getText() + ".");
        }
    });

    return view;
}
}

call findViewById with your view object.

btnzero = (Button) view.findViewById(R.id.btnzero);
btn1 = (Button) view.findViewById(R.id.btn1);
btn2 = (Button) view.findViewById(R.id.btn2);

and go on.

Replace your all findViewById by below code.

btnzero = (Button) view.findViewById(R.id.btnzero);
    btn1 = (Button) view.findViewById(R.id.btn1);
    btn2 = (Button) view.findViewById(R.id.btn2);
    btn3 = (Button) view.findViewById(R.id.btn3);
    btn4 = (Button) view.findViewById(R.id.btn4);
    btn5 = (Button) view.findViewById(R.id.btn5);
    btn6 = (Button) view.findViewById(R.id.btn6);
    btn7 = (Button) view.findViewById(R.id.btn7);
    btn8 = (Button) view.findViewById(R.id.btn8);
    btn9 = (Button) view.findViewById(R.id.btn9);
    btnadd = (Button) view.findViewById(R.id.btnadd);
    btndiv = (Button) view.findViewById(R.id.btndiv);
    btnsub = (Button) view.findViewById(R.id.btnsub);
    btnmul = (Button) view.findViewById(R.id.btnmul);
    btndot = (Button) view.findViewById(R.id.btndot);
    btnclear = (Button) view.findViewById(R.id.btnclear);
    btnequal = (Button) view.findViewById(R.id.btnequal);
    textview = (TextView) view.findViewById(R.id.textview);