-
-
Save anonymous/f5feae51009b9f8bc956 to your computer and use it in GitHub Desktop.
/** | |
* This method displays the given text on the screen. | |
*/ | |
private void displayMessage(String message) { | |
TextView priceTextView = (TextView) findViewById(R.id.price_text_view); | |
priceTextView.setText(message); | |
} |
currently the extension to MainActivity in Android Studio is .kt so when I paste de code in Java appears a pop up window with the message to change to kotlin extension but my code is whit 8 errors, I write the right code like catherine said but It still does not work. Can anyone help me?
`package com.example.android.justjava
import android.R
import android.os.Bundle
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import java.text.NumberFormat
/**
-
This app displays an order form to order coffee.
*/
class MainActivity : AppCompatActivity() {var quantity = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}/**
-
This method is called when the increment button is clicked.
*/
fun increment(view: View?) {
var int = quantity
quantity += 1
display (quantity)}
/**
- This method is called when the decrement button is clicked.
*/
fun decrement(view: View?) {
var int = quantity
quantity -= 1
display (quantity)
}
/**
- This method is called when the order button is clicked.
*/
fun submitOrder(view: View?) {
String priceMessage = "Free"
displayMessage(priceMessage)
}
/**
- This method displays the given quantity value on the screen.
*/
private fun display(number: Int) {
val quantityTextView = findViewById(R.id.quantity_text_view) as TextView
quantityTextView.text = "" + number
}
/**
- This method displays the given price on the screen.
*/
private fun displayPrice(number: Int) {
val priceTextView = findViewById(R.id.price_text_view) as TextView
priceTextView.setText(NumberFormat.getCurrencyInstance().format(number))
}
/**
- This method displays the given text on the screen.
*/
private fun displayMessage(message: String) {
val priceTextView = findViewById(R.id.price_text_view) as TextView
priceTextView.text = message
}
}`
-
This string message will help to crash any business in few time!!
public void submit (View view){
String priceTextView = "Free";
displayMessage(priceTextView);
}
/**
- This method displays the given text on the screen.
*/
private void displayMessage(String message) {
TextView priceTextView = (TextView) findViewById(R.id.price_text_view);
priceTextView.setText(message);
}
Thank you! 😊
ok thanks
Thank you
THANK YOU VERY MUCH
Thanksgiving so much
Thanks so much!!
good thank you
"Free"
Thanks!
Very good thank you very much
thanks