title: How do I change button text and function in Android?
body: <p>I am an Android beginner. Here is what I am trying to do. I have an activity UI with three buttons. A second activity is identical however the buttons text and actions are different. Rather than have it switch intents or activities when buttons are clicked on the the first activity, can I code the buttons to change when clicked? This way I wouldn't need a second identical UI.</p>
  
  <p>The three buttons are Login, SignUp and Tour. When Login or Tour are clicked I do indeed want them to launch different activities. But for "SignUp" this is where the UI would be identical containing the same buttons but different text and will launch different intents. My goal is to eliminate this identical UI and just have the buttons change on the first screen when "Sign Up" is clicked.</p>
  
  <p>Here is my current code which just launches new intents on click. I am not sure where to start to get the functionality I want. Any help is appreciated. Thanks.</p>
  
  <pre><code>import android.support.v7.app.AppCompatActivity
  import android.os.Bundle
  import android.view.View
  import android.content.Intent
  import android.support.v4.content.ContextCompat.startActivity
  
  class MainActivity : AppCompatActivity() {
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
      }
  
      fun login(view: View) {
          val myIntent = Intent(this@MainActivity, LoginActivity::class.java)
          this@MainActivity.startActivity(myIntent)
      }
  
      fun signUpAs(view: View) {
          val myIntent = Intent(this@MainActivity, SignUpAsActivity::class.java)
          this@MainActivity.startActivity(myIntent)
      }
  
      fun tour(view: View) {
          val myIntent = Intent(this@MainActivity, TourActivity::class.java)
          this@MainActivity.startActivity(myIntent)
      }
  
      override fun onWindowFocusChanged(hasFocus: Boolean) {
          super.onWindowFocusChanged(hasFocus)
          if (hasFocus) {
              val decorView = window.decorView
              decorView.setSystemUiVisibility(
                      View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
          }
      }
  
  }
  </code></pre>