Display Count of Notifications in Android App Launcher Icon

Smita Kapse
Updated on 30-Jul-2019 22:30:26

3K+ Views

This example demonstrate about How to display count of notifications in Android app launcher icon.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                                                                         Let's try to run your application. I assume you have connected ... Read More

Check If Two Nodes Are Equal in a JTree with Java

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

833 Views

To check if two nodes are equal, use the equals() method. Here, we are checking that node1 and node2 are equal or not.node1.equals(node2)The following is an example to check if two nodes are equal in a JTree −package my; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame frame = new JFrame("Demo");       DefaultMutableTreeNode node = new DefaultMutableTreeNode("Website");       DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("Videos");       DefaultMutableTreeNode node2 = new DefaultMutableTreeNode("Tutorials");       DefaultMutableTreeNode node3 = new DefaultMutableTreeNode("QA");     ... Read More

Make JSlider Vertical and Move Top to Bottom in Java

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

283 Views

To set the JSlider to be vertical, use the VERTICAL constant while creating the slider −JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 60);Now, for the inverted slider i.e. moving from top-to-bottom −slider.setInverted(true);The following is an example to set the slider vertical and move top-to-bottom −Examplepackage my; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.WindowConstants; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame("Frame with Slider");       JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 60);       slider.setInverted(true);       slider.setMinorTickSpacing(5);       slider.setMajorTickSpacing(20);     ... Read More

Find Documents That Contain Specific Field in MongoDB

Chandu yadav
Updated on 30-Jul-2019 22:30:26

195 Views

For this, use the $exists operator. Let us first create a collection with documents −>dbfindDocumentContainsSpecificFieldDemoinsertOne({"ProductPrices":{"Product1":10, "Pr oduct2":50}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf2385bb64a577be5a2bc14") } >dbfindDocumentContainsSpecificFieldDemoinsertOne({"ProductPrices":{"Product3":150, "P roduct7":100, "Product5":250}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cf2387eb64a577be5a2bc15") }Following is the query to display all documents from a collection with the help of find() method −> dbfindDocumentContainsSpecificFieldDemofind()pretty();This will produce the following document −{    "_id" : ObjectId("5cf2385bb64a577be5a2bc14"),    "ProductPrices" : {       "Product1" : 10,       "Product2" : 50    } } {    "_id" : ObjectId("5cf2387eb64a577be5a2bc15"),    "ProductPrices" : {       ... Read More

HTML DOM Input URL Disabled Property

AmitDiwan
Updated on 30-Jul-2019 22:30:26

164 Views

The HTML DOM Input URL disabled property sets/returns whether Input URL is enabled or disabled.SyntaxFollowing is the syntax −Returning boolean value - true/falseinputURLObject.disabledSetting disabled to booleanValueinputURLObject.disabled = booleanValueBoolean ValuesHere, “booleanValue” can be the following −booleanValueDetailsTrueIt defines that the input url is disabled.FalseIt defines that the input url is not disabled and it is also the default value.ExampleLet us see an example of Input URL disabled property − Live Demo Input Email disabled    form {       width:70%;       margin: 0 auto;       text-align: center;    }    * {       ... Read More

What is Long Long in C/C++

Samual Sam
Updated on 30-Jul-2019 22:30:26

8K+ Views

In some cases we use long long in C or C++. Here we will see what is basically long long is? The long long takes twice as much memory as long. In different systems, the allocated memory space differs. On Linux environment the long takes 64-bit (8-bytes) of space, and the long long takes 128-bits (16-bytes) of space. This is used when we want to deal with some large value of integers.We can test the size of different types using this simple program.Example#include using namespace std; main() {    int a;    long b;    long long c;    cout

Problem Using the Field 'FROM' in SQL Query

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

122 Views

You cannot use from as a column name directly because from is a reserved word in MySQL. To avoid this, you need to use backtick symbol. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    `from` varchar(100),    Name varchar(10)    ); Query OK, 0 rows affected (0.92 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(`from`, Name) values('US', 'John'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(`from`, Name) values('UK', 'Carol'); Query OK, 1 row affected (0.14 sec) mysql> ... Read More

What is iterweekdays in Python

Ranjit Kumar
Updated on 30-Jul-2019 22:30:26

428 Views

iterweekdays() method. The iterweekdays() method returns an iterator for the weekday numbers that will be used for one week.Example#Write a python program to print iterweekdays() using list import calendar # prints firstweekday starts with 4 th day day= calendar.Calendar(firstweekday = 4) list(day.iterweekdays())Output[4, 5, 6, 0, 1, 2, 3]Orimport calendar #prints firstweekday starts with 0 th day variable= calendar.Calendar(firstweekday = 0) for day in variable.iterweekdays(): print(day)Output0 1 2 3 4 5 6

Create a Date Spinner in Java

Smita Kapse
Updated on 30-Jul-2019 22:30:26

2K+ Views

To create a date spinner, use the SpinnerDateModel class. Within that set the date format −Date today = new Date(); JSpinner spinner2 = new JSpinner(new SpinnerDateModel(today, null, null, Calendar.MONTH)); JSpinner.DateEditor editor = new JSpinner.DateEditor(spinner2, "dd/MM/yy"); spinner2.setEditor(editor);Above, we have set the Date format to be −dd/MM/yyThe following is an example to create a date spinner in Java −Examplepackage my; import java.awt.GridBagLayout; import java.util.Calendar; import java.util.Date; import javax.swing.*; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame("Spinner Demo");       JPanel panel = new JPanel();       JLabel label = new JLabel("Exam No.");       JLabel label2 = new JLabel(" Appeared On");       panel.setLayout(new GridBagLayout());       int min = 0;       int max = 10;       int step = 1; ... Read More

Customize Tooltip Font Color and Background in Java

George John
Updated on 30-Jul-2019 22:30:26

2K+ Views

To customize the tooltip font, color and background, use UIManager.UIManager.put("ToolTip.background", Color.ORANGE); UIManager.put("ToolTip.foreground", Color.BLACK); UIManager.put("ToolTip.font", new Font("Arial", Font.BOLD, 14));Above, we have set the font with −Tooltip.fontWe have set the foreground and background color with the following above −ToolTip.foreground ToolTip.backgroundThe following is an example to customize tooltip −Examplepackage my; import java.awt.Color; import java.awt.Font; import java.awt.GraphicsEnvironment; import java.awt.GridLayout; import java.awt.Point; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.UIManager; public class SwingDemo {    public static void main(String[] args) throws Exception {       JFrame.setDefaultLookAndFeelDecorated(true);       JFrame frame = new JFrame("Register!");       JLabel label1, label2, ... Read More

Advertisements