Regardless of which of the two check boxes is checked, I would like to change calendarview to visible. The default status for xml is invisible. The error keeps appearing on the second override, so I would appreciate it if you could tell me what the problem is and which part I should change. It's very difficult because it's my first time dealing with Java and I know it by looking at the example.
package com.example.ansimyoyang_ipsoza;
import android.os.Bundle; import android.view.View; import android.widget.CalendarView; import android.widget.CheckBox; import android.widget.CompoundButton;
import androidx.appcompat.app.AppCompatActivity;
public class meetingbook extends AppCompatActivity {
CheckBox checkbox_facebook;
CheckBox checkbox_nofacebook;
CalendarView calendarView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
checkbox_facebook = (CheckBox)findViewById(R.id.checkbox_facebook);
checkbox_nofacebook = (CheckBox)findViewById(R.id.checkbox_nofacebook);
calendarView=(CalendarView)findViewById(R.id.calendarView);
checkbox_facebook.setOnCheckedChangeListener((CompoundButton.OnCheckedChangeListener) this);
checkbox_nofacebook.setOnCheckedChangeListener((CompoundButton.OnCheckedChangeListener) this);
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(checkbox_facebook.isChecked()) calendarView.setVisibility(View.VISIBLE);;
if(checkbox_nofacebook.isChecked()) calendarView.setVisibility(View.VISIBLE);
}
}
android
The annotation @Override means that this method overrides a predefined method for an inherited parent or implemented interface.
Currently, the meetingbook class of the code inherits AppCompatActivity. This parent class does not have a method defined called onCheckedChanged.
//public class meetingbook extends AppCompatActivity
public class meetingbook extends AppCompatActivity implements OnCheckedChangeListener
Please change it like this.
554 Understanding How to Configure Google API Key
560 PHP ssh2_scp_send fails to send files as intended
555 Who developed the "avformat-59.dll" that comes with FFmpeg?
782 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
557 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.