Answer the question
In order to leave comments, you need to log in
MainActivity.java how to fix error?
you need the button to be clickable, public void onClick(View view - this marks red):
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, PreferenceScreen.class);
startActivity(intent);
}
an error occurs:
Error:(121, 13) error: illegal start of expression
Error:(121, 20) error: illegal start of expression
Error:(121, 32) error: ';' expected
Error:(121, 33) error: not a statement
Error:(121, 37) error: ';' expected
Error:(121, 39) error: not a statement
Error:(121, 43) error: ';' expected
Answer the question
In order to leave comments, you need to log in
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent =new Intent(MainActivity.this, PreferenceScreen.class);
startActivity(intent);
}
});
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question