Posts

Showing posts from September, 2021

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