Check if recyclerview is empty

if (recyclerview.getItemCount() == 0) { Toast.makeText(getActivity(), "No records to show!", Toast.LENGTH_SHORT).show(); }if (recyclerview.getItemCount() == 0) { Toast.makeText(getActivity(), "No records to show!", Toast.LENGTH_SHORT).show(); }

Current date in android studio

Android java set current Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String strDate = sdf.format(c.getTime()); Log.d("Date","DATE : " + strDate)Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String strDate = sdf.format(c.getTime()); Log.d("Date","DATE : " + strDate) Android java get current import java.time.*; LocalDate date = LocalDate.now();import java.time.*; LocalDate date = … Read more

Java full screen jFrame

frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setUndecorated(true); frame.setVisible(true);

import math java

import java.lang.Math.*; Example class MathJava { public static void main(String[] args) { // Declaring the variables int num1 = -2; float num2 = .8f; // Printing the values System.out.println(“Initial value of int : “+num1); System.out.println(“Initial value of int : “+num2); // Use of .abs() method to get the absoluteValue int Absi = Math.abs(num1); float Absf … Read more

Java int to roman

import java.util.TreeMap; class IntToRoman { public final static String toRoman(int number, TreeMap romanIdentifiers) { int l = romanIdentifiers.floorKey(number); if (number == l) { return romanIdentifiers.get(number); } return romanIdentifiers.get(l) + toRoman(number – l, romanIdentifiers); } public static void main(String[] args) { final TreeMap romanIdentifiers = new TreeMap(); romanIdentifiers.put(1000, “M”); romanIdentifiers.put(900, “CM”); romanIdentifiers.put(500, “D”); romanIdentifiers.put(400, “CD”); romanIdentifiers.put(100, … Read more

Androidx recyclerview dependency

dependencies { implementation "androidx.recyclerview:recyclerview:1.1.0" // For control over item selection of both touch and mouse driven selection implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc01" }dependencies { implementation "androidx.recyclerview:recyclerview:1.1.0" // For control over item selection of both touch and mouse driven selection implementation "androidx.recyclerview:recyclerview-selection:1.1.0-rc01" }

jLabel text center

JLabel label = new JLabel(“Label Text Here”, SwingConstants.CENTER);

Phone vibrate java android studio

// Vibrate for 90 milliseconds private void shakeItBaby() { if (Build.VERSION.SDK_INT >= 26) { ((Vibrator) getSystemService(VIBRATOR_SERVICE)) .vibrate(VibrationEffect.createOneShot(90, VibrationEffect.DEFAULT_AMPLITUDE)); } else { ((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(90); } }// Vibrate for 90 milliseconds private void shakeItBaby() { if (Build.VERSION.SDK_INT >= 26) { ((Vibrator) getSystemService(VIBRATOR_SERVICE)) .vibrate(VibrationEffect.createOneShot(90, VibrationEffect.DEFAULT_AMPLITUDE)); } else { ((Vibrator) getSystemService(VIBRATOR_SERVICE)).vibrate(90); } }