Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help to complete this code in AndroidStudio Need the button to be working if I click on Hi button , output to be Hi

Need help to complete this code in AndroidStudio

Need the button to be working if I click on Hi button , output to be Hi and if i click on Bye button output to be Bye

Here is my Code so far :-

package com.kean.hibye_olanread; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends AppCompatActivity { //DECLARE TEXT REFERENCE TO THE INTERFACE LAYOUT COMPONENT  private TextView greetingTextView; //INDICATES WELCOME IS CURRENTLY DISPLAYED // private boolean isPushaButton; // private boolean isWelcome;  private Button hiBtn; private Button byeBtn; @Override protected void onCreate(Bundle savedInstanceState) { // task1  super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Taxt2   greetingTextView = (TextView) findViewById(R.id.textView2); hiBtn = (Button) findViewById(R.id.button2); byeBtn = (Button) findViewById(R.id.button); // Button exclaimBtn = (Button) findViewById(R.id.button);   // Task4  hiBtn.setOnClickListener(toggleGreeting); byeBtn.setOnClickListener(toggleGreeting); } public final View.OnClickListener toggleGreeting = new View.OnClickListener() { public void onClick(View btn) { greetingTextView.setText("Bye"); greetingTextView.setText("Hi"); } }; } Initial image image text in transcribed 
LTE a 9:02 HiBye_Olanread Push a Button Welcome BYE

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

Are these written ground rules?

Answered: 1 week ago

Question

Have ground rules been established for the team?

Answered: 1 week ago