Could somebody tell me if there is anything wrong in the program shown below?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int addAToB(int a, int b)
{
int answer = a + b;
return answer;
}
}
I am a complete beginner in Android App Development and am facing this problem for quite some time . Whenever I make any method Android Studio is showing errors. Another example is this one.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(this, "Can you see me", Toast.LENGTH_SHORT).show();
public void topClick (View v){
Toast.makeText(this, "Top button clicked", Toast.LENGTH_SHORT).show();
}
public void bottomClick (View v){
Toast.makeText(this, "Bottom button clicked", Toast.LENGTH_SHORT).show();
}
}
It's an app in which two buttons are created and whenever the user clicks the top button a message of "Top button clicked" is shown and whenever the user clicks the button at the bottom a message of "Bottom button clicked" is shown.
I have reinstalled Android Studio twice in the hope the it might solve the issue but it didn't.