الهدف الرئيس من هذا الفيديو التعليمي هو التعرف على مفهوم variables & strategies واستخدامهم في تطبيق بواسطة android studio والبرمجة بلغة الجافا بشكل مبسط جداً. وأيضا وفي السياق استخدام بسيط لـ constraint format وتفعيل استخدام الأزرار buttons وكذلك system crash
الجزء التالي هو كود البرمجة بلغة الجافا والتي يفترض لصقها داخل الملف ActivityMain.java وذلك وفقا للفيديو التعليمي
/**
* IMPORTANT: Be sure you are utilizing the proper bundle title.
* This instance makes use of the bundle title:
* bundle com.instance.android.justjava
* If you happen to get an error when copying this code into Android studio, replace it to match the bundle title discovered
* within the mission’s AndroidManifest.xml file.
**/
import android.os.Bundle;
import android.help.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
import java.textual content.NumberFormat;
/**
* This app shows an order kind to order espresso.
*/
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
tremendous.onCreate(savedInstanceState);
setContentView(R.format.activity_main);
}
public void submitOrder(View view){
show(5);
displayPrice(amount*2);
}
}
/**
* This methodology known as when the order button is clicked.
*/
public void show(int quantity) {
TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view);
quantityTextView.setText(“” + quantity);
}
/**
* This methodology shows the given worth on the display screen.
*/
personal void displayPrice(int quantity) {
TextView priceTextView = (TextView) findViewById(R.id.price_text_view);
priceTextView.setText(NumberFormat.getCurrencyInstance().format(quantity));
}
}
source
Baking sourdough bread and watching TikTok may only take you so far, especially on days…
Now, firecrackers might be the first thing that pops into your head when you hear…
Every day, as the sun rises over the picturesque city of Fort Collins, a dedicated…
Precision mold parts are indispensable in production processes that demand precise dimensions. Their increased durability,…
Boat rentals provide the ideal way to explore Malta's breathtaking beaches and waters, including hidden…
Introduction In the agricultural sector, the quality of wheat directly influences the quality of the…