You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
#52
Open
Ashley-Deans opened this issue
May 26, 2020
· 0 comments
I tried using the example code at the bottom of the page to test it out. But I'm getting this error whenever I put the java code in. Otherwise the XML part works fine. But the minute I put the java code the function setOnClickedButtonListener and OnPositionChangedListener just causes the app to crash.
Main Activity
packagecom.masslabs.myapplication;
importandroidx.appcompat.app.AppCompatActivity;
importandroid.os.Bundle;
importandroid.widget.Toast;
importco.ceryle.radiorealbutton.RadioRealButton;
importco.ceryle.radiorealbutton.RadioRealButtonGroup;
publicclassMainActivityextendsAppCompatActivity {
finalRadioRealButtonbutton1 = (RadioRealButton) findViewById(R.id.button1);
finalRadioRealButtonbutton2 = (RadioRealButton) findViewById(R.id.button2);
RadioRealButtonGroupgroup = (RadioRealButtonGroup) findViewById(R.id.group);
@OverrideprotectedvoidonCreate(BundlesavedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// onClickButton listener detects any click performed on buttons by touchgroup.setOnClickedButtonListener(newRadioRealButtonGroup.OnClickedButtonListener() {
@OverridepublicvoidonClickedButton(RadioRealButtonbutton, intposition) {
Toast.makeText(MainActivity.this, "Clicked! Butten: " + button.getText(), Toast.LENGTH_SHORT).show();
}
});
// onPositionChanged listener detects if there is any change in positiongroup.setOnPositionChangedListener(newRadioRealButtonGroup.OnPositionChangedListener() {
@OverridepublicvoidonPositionChanged(RadioRealButtonbutton, intcurrentPosition, intlastPosition) {
Toast.makeText(MainActivity.this, "Button Changed! Text: " + button.getText(), Toast.LENGTH_SHORT).show();
}
});
}
}
I tried using the example code at the bottom of the page to test it out. But I'm getting this error whenever I put the java code in. Otherwise the XML part works fine. But the minute I put the java code the function setOnClickedButtonListener and OnPositionChangedListener just causes the app to crash.
Main Activity
XML File
The text was updated successfully, but these errors were encountered: