public class MainClass extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent1 = new Intent(MainClass.this, SecondClass.class);
startActivity(intent1);
}
//---------------------------------------------
public class SecondClass extends Activity {
ThirdClass thirdclass;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.keyboard);
thirdclass.Random_Method('A');
}
//---------------------------------------------
public class ThirdClass extends Activity {
public void Random_Method(char NewChar) {
}
public class MainClass extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
Share
ThirdClass thirdclass was never initalized. Change the code to
Or, alternatively, do this:
Also, ThirdClass does not need to extend Activity (and it shouldn’t unless you can explain why it needs to).
EDIT:
If it does need to extend Activity then you should be switching to ThirdClass in the same way that MainClass switches to SecondClass with intents. Or rethink the way your activities work so that this TextView happens in SecondClass. The second would be done like: