Posts

Showing posts with the label Android studio

How Create the Exit Dialog-box in Android Studio. | Dialog box | Android Studio

Image
1. Open Android Studio. 2. Create the Dialog Box. 3. Download exit Icon 4. Set Positive and Negative Button. 5.Run the Emulator. CODE:- package com.example.theacx; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import android.content.DialogInterface; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends AppCompatActivity implements Dialbox { public void onBackpressed() { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle("Confirm exit"); alertDialogBuilder.setIcon(R.drawable.ic_exit_to_app_black_24dp); alertDialogBuilder.setMessage("Are you Sure want to Exit"); alertDialogBuilder.setCancelable(false); alertDialogBuilder.setPositiveButton("yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogI...

How to create Splashscreen | Android Studio.

Image
                             Splashscreen 1)Open Android Studio. 2)Create one empty activity. 3)Import the image. 4)Goto java and create the New handler activity  and set delay time. 5) Run the Emulater. Code for xml:- <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     tools:context=".MainActivity"> <ImageView     android:layout_width="match_parent"     android:src="@drawable/logo"     android:layout_margin="10dp"     android:id="@+id/img"     android:background="#CFAB62"     android:layout_height="300dp"/>   ...

How to create Cardview with Toast | Cardview | Toast | Android Studio.

Image
How to create Cardview with Toast  1)Open the Android Studio. 2)Go to build.gradle (module app) 3)In  import  dependencies the cardview implementation  (implementation 'androidx.cardview:cardview:1.0.0') 4)Click on sync. 5)Then come to Layout file and start writing the code for cardview. 6)Go-to java file and decleare the cardview. 7)Set the path for cardview. 8)Then set the click activity and write the code for Toast. 9)Run the emulator(check the output). Code for Xml file:- <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     tools:context=".homeactivity"> <androidx.cardview.widget.CardView     android:layo...

How to add Image and Edit-text in Android Studio | Edit Text | Android Studio.

Image
How to  add  Image and Edit-text in Android Studio. Step:- 1)Open the Android Studio. 2)Copy the image and paste in a drawable folder in res. 3) Then the go-to Layout. 4)Write the code and set the path for image(src:). 5)Then run the emulator(check the output). 6)Then Come again Layout and write the code for Edit text. 7)Again run the emulator(check the output). Code:- 1) Image Refer src:- android:src="@drawable/logo" 2) xml code image  <ImageView             android:layout_width="225dp"             android:layout_height="204dp"             android:layout_margin="20dp"             android:layout_gravity="center"             android:src="@drawable/logo"/> 3) xml code edit-text <EditText android:layout_width="match_parent" android:hint="Username" android:textAli...

Android Studio Introduction | Basic Android Studio | Android Studio.

Image
Android Studio Introduction. Introduction : Android Studio is the official integrated development environment (IDE) for Google's Android operating system, built on JetBrains' IntelliJ IDEA software and designed specifically for Android development.   It is available for download on Windows, macOS and Linux based operating systems. ● Type: Integrated development environment. ● Developer: Google, JetBrains. ● Languages used: Java. ● Manifests : Every project in Android includes a manifest file, which is Manifest, stored in the root directory of its project hierarchy. It is important file because it defines structure, metadata, components, and its requirements. ● Java : The Java folder contains the Java source code files. It works on the backend of an Android application.  It gets the data from the Layout file and after processing that data output will be shown in the UI layout. ...

How to Create the Button in Android Studio. | Button | Android Studio.

Image
How to Create a Button in Android studio. To create Button Code.XML:- <Button     android:layout_width="200dp"     android:layout_height="60dp"     android:id="@+id/btn_submit"     android:layout_below="@id/et_password"     android:layout_centerHorizontal="true"     android:layout_marginTop="20dp"     android:textColor="#0A0A0A"     android:textSize="25dp"     android:text="submit" /> Code.java:- 1) Declare the Button      Button btn; 2)Set the Path  btn= findViewById(R.id.buttonone); 3) Clicking Activity btn.setOnClickListener(new View.OnClickListener() {     @Override     public void onClick(View v) {         Intent i = new Intent(mainActivity.this,HomeActivity.class);         startActivity(i);         }     }; You can refer this video in...