Andriod Studio
//you have to modify the application name, my name, and somethings here
// for example: package com.example.myname.myapplicationname;
package com.example.fmili.gettingstarted;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.appindexing.Thing;
import com.google.android.gms.common.api.GoogleApiClient;
import static android.R.id.message;
import static com.example.fmili.gettingstarted.R.id.price_text_view;
import static com.example.fmili.gettingstarted.R.id.quantityView;
public class MainActivity extends AppCompatActivity {
int quantity =1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
}
public void moreDragons(View view) {
quantity = quantity + 1;
displayQuantity(quantity);
}
private void displayQuantity(int quantity) {
TextView priceTextView = (TextView) findViewById(quantityView);
priceTextView.setText(String.valueOf(quantity));
}
public void fewerDragons(View view) {
quantity = quantity - 1;
displayQuantity(quantity);
}
public void orderDragons(View view) {
String priceMessage = String.valueOf(quantity * 100);
displayAmount(priceMessage);
}
/**
* This method displays the given text on the screen.
*/
private void displayAmount(String message) {
TextView priceTextView = (TextView) findViewById(price_text_view);
priceTextView.setText(message);
}
}