Expression Expected error
43,690
You must delete this line Button advanceToQuestionTwo = {Button};
or complete it. You need to put (Button)
and not {Button}
. Then after that you should call findViewById( id of that button in the xml file)
.
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on July 09, 2022Comments
-
Admin almost 2 years
In Android Studio I want to a button to start a new Activity. I get an Expression Expected error. Where have I gone wrong?
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button advanceToQuestionTwo = {Button}; Button loadNewActivity = (Button) findViewById(R.id.imageButton); loadNewActivity.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this, Stundenplan.class); startActivity(intent); } }); }