Why I can not call the method inside Fragment


Why is it not possible to call the checkButtonAddmethod in my Fragment?

public class AddDataFragment extends Fragment {
    DbHelper mydb;

    Button buttonadd;
    Button buttondelete;

    private EditText inputLabel;

    //Validator boolean
    public boolean labelOk;

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

        final Context context = getContext();
        mydb = new DbHelper(context);


        inputLabel = (EditText) view.findViewById(R.id.editText_label);
        inputLabel.addTextChangedListener(new TextWatcher() {
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

            public void onTextChanged(CharSequence s, int start, int before, int count) {}

            public void afterTextChanged(Editable s) {
                Pattern p = Pattern.compile("^[A-Z]{3}-[0-9]{4}$");
                Matcher m = p.matcher(s);

                labelOk = m.find();
                Log.d("ButtonAdd?", String.valueOf(labelOk));
            checkButtonAdd(); // <---------------


        return view;

    public void checkButtonAdd(){
        if (labelOk){

I thought this should work because I used it in another Application. But in the MainActivitiy could this be the mistake and if yes, how can I solve it?

You have to call that method from one of the callback methods using this keyword, to get the instance of enclosing Fragment. For instance..

public void afterTextChanged(Editable s) {
    // Your Statements

No need to declare the method as static. In fact, declaring it static will be a piece of poor code