Posts

Toast in Android.

 Toast in Android.  /    SNACKBAR / (for permanent display notification can be used) sdfsdf / Toast . makeText ( MainActivity . this , "login Successfully" , Toast . LENGTH_SHORT ) . show(); Context context = getApplicationContext (); CharSequence text = "Hello toast!" ; int duration = Toast . LENGTH_SHORT ; Toast toast = Toast . makeText ( context , text , duration ); toast . show (); FOR STYLEABLE TOAST First implement latest dependency. dependencies { implementation 'io.github.muddz:styleabletoast:2.4.0' } Next, go to values -> style -> create new <style name = "signuptoast"> layout < style name ="signupToast" > < item name ="stColorBackground" > #228B22 </ item > < item name ="stTextBold" > true </ item > < item name ="stTextColor" > #fff </ item > < item name ="stFont" > @font/retrofont </ item

while loop in java.

1. 1 2 3 4 5 6 7 8 9 10 int i = 1 ; while ( i <= 10 ) { System . out . println ( i ); i ++ ; } Q2. What will be output of this program. int x = 4 , y , z ; y =-- x ; z = x -- ; System . out . println ( x ); System . out . println ( y ); System . out . println ( z ); output:- 2 3 3 Q3. What will be output of this program. int x = 4 , y = 3 , z ; z = x -- - y ; System . out . println ( x ); System . out . println ( y ); System . out . println ( z ); output:- 3 3 1 Q4. What will be output of this program. package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { double i = 1.1 ; while ( i == 1.1 ) { System . out . println ( i ); i = i - 0.1 ; } } } output:- 1.1

How to implement animation or lottie files in android.

Image
 How to implement animation or lottie files in android. First of all, implement latest dependency in build.gradle file. implementation 'com.airbnb.android:lottie:4.1.0' //for lottie files Create one raw folder and put your JSON file in that Then in xml file put this code. < com.airbnb.lottie.LottieAnimationView android :id ="@+id/animationView" android :layout_width ="100dp" android :layout_height ="80dp" app :lottie_autoPlay ="true" app :lottie_loop ="true" app :lottie_rawRes ="@raw/lottie" /> //here put your own lottie file have a great day.  

how to reverse number

 HOW TO REVERSE A NUMBER take varible  int number; //to store original or to get quotient int rev; //to decrease the number int reverse_number = 0; //to store reverse number First take input from user.( number=5364 ) then run one while loop condition while(number>0) under loop rev = number%10; //we get rev =536 //take another variable reverse_number reverse_number = reverse_number*10+rev; //we get reverse_number= 4 number=number/10; //now number= 536 package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // reverse number program int number , rev , reverse_number = 0 ; System . out . println ( "Enter a number" ); Scanner sc = new Scanner ( System . in ); number = sc . nextInt (); while ( number > 0 ) { rev = number % 10 ; reverse_number = reverse_number * 10 + rev ; number = number / 10 ; } System . out . println (

write a program to check whether a triangle is valid or not, when the threeangles of the triangle are entered through the keyboard. A triangle is valid if the sumof all the three angles is equal to 180 degrees

  /*write a program to check whether a triangle is valid or not, when the three angles of the triangle are entered through the keyboard. A triangle is valid if the sum of all the three angles is equal to 180 degrees. */ package com.company ; import javax.security.sasl. SaslClient ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here int a , b , c , sum ; //angle of triangle Scanner angle = new Scanner ( System . in ); System . out . print ( "side a : " ); a = angle . nextInt (); System . out . print ( "side b : " ); b = angle . nextInt (); System . out . print ( "side c : " ); c = angle . nextInt (); //sum of angle of trinagle sum = a + b + c ; if ( sum == 180 ) { System . out . println ( "Triangle is valid" ); } else System . out . println (

HOW TO RETRIVED IMAGE FROM FIREBASE IN ANDROID

 HOW TO RETRIVED IMAGE FROM FIREBASE IN   ANDROID add Dependences in build.gradle file dependencies {     // Import the BoM for the Firebase platform     implementation platform ( 'com.google.firebase:firebase-bom:28.4.0' )     // Declare the dependency for the Cloud Storage library     // When using the BoM, you don't specify versions in Firebase library dependencies     implementation 'com.google.firebase:firebase-storage-latest version'//include latest version Add Imageview in xml to retrived image < ImageView android :id ="@+id/image" android :layout_width ="wrap_content" android :layout_height ="wrap_content" app :layout_constraintBottom_toBottomOf ="parent" app :layout_constraintEnd_toEndOf ="parent" app :layout_constraintStart_toStartOf ="parent" app :layout_constraintTop_toTopOf ="parent" app :layout_constraintVertical_bias ="0.966" android

Leap year or not in java.

  Formula to calculate leap year. Identify the year we want to know if its a leap year. We then divide the year by 4 to check if its evenly divisible. Then confirm that the year is not evenly divisible by 100. Check if the year is divisible by 400. If the year is evenly divisible by 4, then the year is a leap year. If the year is only evenly divisible by 100 and not evenly divisible by 400, then the year is not a leap year. package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here int year ; Scanner sc = new Scanner ( System . in ); System . out . print ( "Enter year : " ); year = sc . nextInt (); if (( year % 4 == 0 ) && ( year % 100 != 0 ) && ( year % 400 != 0 )) { System . out . println ( year + " is Leap Year" ); } else { System . out . println ( year + " is Not L

Number is even or odd in java

  package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here int a ; System . out . println ( "Enter a number : " ); Scanner sc = new Scanner ( System . in ); a = sc . nextInt (); if ( a % 2 == 0 ) { System . out . println ( "Even number" ); } System . out . println ( "Odd number" ); } } Enter a number : 23 Odd number Process finished with exit code 0

If coast price and selling price of an item are input through the keyboard. Write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred.

  //.If coast price and selling price of an item are input through the keyboard. // Write a program to determine whether the seller has made profit or incurred loss. // Also determine how much profit he made or loss he incurred. package com.company ; import java.util.Scanner ; public class Main { public static void main ( String [] args ) { // write your code here int costPrice , sellingPrice , profit , loss ; Scanner sc = new Scanner ( System . in ); System . out . print ( "Enter cost price : " ); costPrice = sc . nextInt (); System . out . print ( "Enter selling price : " ); sellingPrice = sc . nextInt (); if ( sellingPrice > costPrice ) { profit = sellingPrice - costPrice ; System . out . println ( "Seller has made profit : " + profit + " ₹ " ); } else { loss = costPrice - sellingPrice ; System . o

Toast

Image
  TOAST   A Toast is short message display on the screen. Toast provide simple feedback message with a popup message. Toast automatically disappear after a timeout. Example :-   clicking  Send  on an email triggers a "Sending message..." toast. Context context = getApplicationContext (); CharSequence text = "Hello Shraddha Nand Pandey" ; int duration = Toast . LENGTH_SHORT ; Toast toast = Toast . makeText ( context , text , duration ); toast . show ();// in built function to show toast XML CODE:- <? xml version ="1.0" encoding ="utf-8" ?> < androidx.constraintlayout.widget.ConstraintLayout 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 =".MainActiv