Bluetooth onClickView ошибка - PullRequest
       0

Bluetooth onClickView ошибка

0 голосов
/ 05 августа 2011

Это фрагмент кода из моей основной деятельности, появляется ошибка, и я не понимаю, в чем дело?

Ошибка: void - недопустимый тип для переменной onClick.

Я новичок в Android и Java, так что это может быть довольно просто .. Спасибо.

private void startApp(){

        View Patient_Button = findViewById(R.id.patientButton);
        Patient_Button.setOnClickListener(this);
        View Doctor_Button = findViewById(R.id.doctorButton);
        Doctor_Button.setOnClickListener(this);
        View About_Option = findViewById(R.id.aboutButton);
        About_Option.setOnClickListener(this);
        View Exit_Option = findViewById(R.id.exit);
        Exit_Option.setOnClickListener(this);

Error:        public void onClick(View v) {
            switch (v.getId()) {
            case R.id.patientButton:
                Intent b = new Intent(this, Detailed_ModeActivity.class);
                startActivity(b);
                break;
            case R.id.doctorButton:
                Intent a = new Intent(this, Detailed_ModeActivity.class);
                startActivity(a);
                break;
            case R.id.aboutButton:
                Intent i = new Intent(this, About.class);
                startActivity(i);
                break;
            case R.id.exit:
                finish();
                break;
            }

        };

    }

Я знаю, что ошибка как-то связана с пустотой, но обычно она работала до

1 Ответ

0 голосов
/ 05 августа 2011

двигаться дальшеНажмите из startApp:)

private void startApp(){

    View Patient_Button = findViewById(R.id.patientButton);
    Patient_Button.setOnClickListener(this);
    View Doctor_Button = findViewById(R.id.doctorButton);
    Doctor_Button.setOnClickListener(this);
    View About_Option = findViewById(R.id.aboutButton);
    About_Option.setOnClickListener(this);
    View Exit_Option = findViewById(R.id.exit);
    Exit_Option.setOnClickListener(this);
}

 public void onClick(View v) {
        switch (v.getId()) {
        case R.id.patientButton:
            Intent b = new Intent(this, Detailed_ModeActivity.class);
            startActivity(b);
            break;
        case R.id.doctorButton:
            Intent a = new Intent(this, Detailed_ModeActivity.class);
            startActivity(a);
            break;
        case R.id.aboutButton:
            Intent i = new Intent(this, About.class);
            startActivity(i);
            break;
        case R.id.exit:
            finish();
            break;
        }

 }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...