In this video it shows how to leverage the power of AI to streamline your Android app development. With tools like Gemini integrated directly into Android Studio, you can now significantly accelerate the app creation process. This AI assistance helps you build core functionalities and features in a fraction of the time, freeing you to focus on the unique aspects of your app.
Prompts used in this demonstration are:
- Android Calculator App Java code
- can you please give layout xml file also for this?
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
Complete source code and other details:
Generated Code:
package com.programmerworld.gemini_calculatorapp;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
private EditText mBillEditText;
private EditText mTipPercentageEditText;
private Button mCalculateButton;
private TextView mTipTextView;
private TextView mTotalTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBillEditText = findViewById(R.id.bill_edit_text);
mTipPercentageEditText = findViewById(R.id.tip_percentage_edit_text);
mCalculateButton = findViewById(R.id.calculate_button);
mTipTextView = findViewById(R.id.tip_text_view);
mTotalTextView = findViewById(R.id.total_text_view);
mCalculateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
calculateTip();
}
});
}
private void calculateTip() {
String billString = mBillEditText.getText().toString().trim();
String tipPercentageString = mTipPercentageEditText.getText().toString().trim();
if (billString.isEmpty() || tipPercentageString.isEmpty()) {
return;
}
double bill = Double.parseDouble(billString);
double tipPercentage = Double.parseDouble(tipPercentageString) / 100;
double tip = bill * tipPercentage;
double total = bill + tip;
mTipTextView.setText(String.format("Tip: $%.2f", tip));
mTotalTextView.setText(String.format("Total: $%.2f", total));
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<EditText
android:id="@+id/bill_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Bill Amount"
android:inputType="numberDecimal" />
<EditText
android:id="@+id/tip_percentage_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Tip Percentage (%)"
android:inputType="numberDecimal" />
<Button
android:id="@+id/calculate_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Calculate" />
<TextView
android:id="@+id/tip_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Tip:"
android:textSize="18sp" />
<TextView
android:id="@+id/total_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Total:"
android:textSize="18sp" />
</LinearLayout>
Screenshots:
Demo of the app
Generating the code using Gemini:
Complete Project files can be accessed at the below google drive link on payment of USD 9:
https://drive.google.com/file/d/1nNDFDP4Nllx6ueKELa6PjNPAzyOslDde/view?usp=drive_link
Learn how to use AI-powered tools like Gemini in Android Studio for faster app development. This video tutorial covers Java code and XML layout setup for an Android Calculator App, demonstrating easy steps to enhance productivity. Watch now for practical insights and download the source code.