Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Am new to android Can anyone pls help correct the error? Am trying to run thid program and am getting this error :- Error:(15, 9)

Am new to android Can anyone pls help correct the error?

Am trying to run thid program and am getting this error :-

Error:(15, 9) error: class, interface, or enum expected

Error:(18, 9) error: class, interface, or enum expected

Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details.

Here is my mainActivity code

package com.kean.myapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.widget.Toolbar; import android.view.View; import android.view.Menu; import android.view.MenuItem; import android.widget.Button; import android.widget.TextView; //DECLARE TEXT REFERENCE TO THE INTERFACE LAYOUT COMPONENT private TextView greetingWelcome; //INDICATES HELLO IS CURRENTLY DISPLAYED private boolean isHi; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); greetingWelcome = (TextView) findViewById(R.id.textView); initializeGreeting(); Button exclaimBtn = (Button) findViewById(R.id.button); exclaimBtn.setOnClickListener(toggleGreeting); //TASK 3: INITIALIZE GREETINGS   } public final View.OnClickListener toggleGreeting = new View.OnClickListener() { public void onClick(View btn) { //Task: CONSTRUCT THE TOGGLE GREETING  if (isHi) { isHi = false; greetingTextView.setText("bye"); } else { isHi = true; greetingTextView.setText("hi"); } } }; private void initializeGreeting() { isHello = true; } /*  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);  setSupportActionBar(toolbar);   FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);  fab.setOnClickListener(new View.OnClickListener() {  @Override  public void onClick(View view) {  Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)  .setAction("Action", null).show();  }  });  */   @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu;  // this adds items to the action bar if it is present.  getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will  // automatically handle clicks on the Home/Up button, so long  // as you specify a parent activity in AndroidManifest.xml.  int id = item.getItemId(); //noinspection SimplifiableIfStatement  if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } ---------------------------------------------------------------------------------------------------- Here is my activity_main.xml 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

Have I incorporated my research into my outline effectively?

Answered: 1 week ago

Question

What were the issues and solutions proposed by each team?

Answered: 1 week ago

Question

3. Who would the members be?

Answered: 1 week ago