Hello guys,
How can I add properties to the button from different pages/class ?
I need to add a property from the otherpage.java page to the button on the mainactivity.java page.But not working. (additional screenshots available)
I shouldn't open the MainActivity page (dont use Intent)
1.Page:Otherpage.java
2.Page: MainActivity.java
Error Detail:
How can I add properties to the button from different pages/class ?
I need to add a property from the otherpage.java page to the button on the mainactivity.java page.But not working. (additional screenshots available)
I shouldn't open the MainActivity page (dont use Intent)
1.Page:Otherpage.java
Java:
holder.btnSepeteEkle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MainActivity main = new MainActivity();
main.test();
}
2.Page: MainActivity.java
Java:
public void test(){
Button buton = findViewById(R.id.buttondeneme);
buton.setText("BUTTON TEST");
}
Error Detail:
Code:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.myapplication9, PID: 5087
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
at android.content.ContextWrapper.getApplicationInfo(ContextWrapper.java:159)
at android.view.ContextThemeWrapper.getTheme(ContextThemeWrapper.java:157)