Group Android Notifications Like WhatsApp

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

890 Views

This example demonstrate about How to group android notifications like whatsappStep 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.     Step 3 − Add the following code to src/MainActivity.javapackage app.tutorialspoint.com.notifyme ; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.content.Context ; import android.support.v4.app.NotificationCompat ; import android.support.v7.app.AppCompatActivity ; import android.os.Bundle ; import android.view.View ; import android.widget.Button ; public class MainActivity extends AppCompatActivity {    public static final String NOTIFICATION_CHANNEL_ID = "10001" ;    private final ... Read More

Update Object at Specific Array Index in MongoDB

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

626 Views

To update object at specific array index, use update() in MongoDB. Let us first create a collection with documents −> db.updateObjectDemo.insertOne( ...   { ...       id : 101, ...       "StudentDetails": ...       [ ...          [ ...             { ...                "StudentName": "John" ...             }, ...             { "StudentName": "Chris" } ...          ], ...          [ { "StudentName": "Carol" }, ... Read More

Set Line Border Color and Width with Java

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

5K+ Views

To set Line Border color and width, use the LineBorder. At first, set a panel wherein we need to set the line border −JPanel panel = new JPanel();Now, create a border and set on the panel created above −Border border = new LineBorder(Color.ORANGE, 4, true); panel.setBorder(border);The following is an example to set LineBorder color and width −package my; import java.awt.Color; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.border.Border; import javax.swing.border.LineBorder; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame();       JPanel panel = new JPanel();   ... Read More

Change Data Type from Date to DateTime in MySQL

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

912 Views

To change data type from date to date/time, use alter command.alter table yourTableName change yourColumnName yourColumnName datetime;Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    LoginDate date    ); Query OK, 0 rows affected (1.26 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(LoginDate) values('2019-01-21'); Query OK, 1 row affected (0.29 sec) mysql> insert into DemoTable(LoginDate) values('2018-05-01'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(LoginDate) values('2017-12-31'); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement ... Read More

Implement Lexicographical Compare in C++ STL

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

142 Views

The C++ function std::algorithm::lexicographical_compare() tests whether one range is lexicographically less than another or not. A lexicographical comparison is the kind of comparison generally used to sort words alphabetically in dictionaries.Declarationtemplate bool lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);AlgorithmBegin    result = lexicographical_compare(v1.begin(), v1.end(), v2.begin(), v2.end())    if (result == true)       Print v1 is less than v2    result = lexicographical_compare(v1.begin(), v1.end(), v2.begin(), v2.end())    if (result == false)       Print v1 is not less than v2 EndExample Live Demo#include #include #include #include using namespace std; int main(void) {    //initialization ... Read More

Use Switch Statement with Strings in Java

Venkata Sai
Updated on 30-Jul-2019 22:30:26

11K+ Views

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.Syntaxswitch(expression) {    case value :       // Statements       break;    case value :       // Statements       break;       // You can have any number of case statements.       default :     // Statements }Strings in switchYes, we can use a switch statement with Strings in Java. While doing so you need ... Read More

HTML DOM Input Hidden Form Property

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

192 Views

The HTML DOM input hidden form property returns the reference of the form that contain the hidden input field in the HTML document.SyntaxFollowing is the syntax −object.formExampleLet us see an example of HTML DOM input hidden form property − Live Demo    body{       text-align:center;       background-color:#363946;       color:#fff;    }    form{       margin:2.5rem auto;    }    button{       background-color:#db133a;       border:none;       cursor:pointer;       padding:8px 16px;       color:#fff;       border-radius:5px;       font-size:1.05rem;   ... Read More

Data Structure for N Elements with O(1) Operations

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

585 Views

Here we will see one data-structure with n elements, and O(1) operations. So the operations will take constant amount of time to execute.The data structure will hold n elements (from 0 to n-1). The data can be in any order. The Insertion, deletion and searching will take O(1) amount of time.To solve this problem, we will use one Boolean array. This will indicate that the item is present or not at position i. If the item is present, it will hold 1, otherwise 0.Algorithminitialization(n)begin    fill all elements of the Boolean array as 0 endinsert(i)begin    set element at index ... Read More

Print the Kth Common Factor of Two Numbers

Sunidhi Bansal
Updated on 30-Jul-2019 22:30:26

357 Views

Given with two numbers x and y the output should contain their kth common factor.Input: x=9 y=18 k=1 Output : k common factor = 2 Factors of 9 : 1, 3, 9 Factors of 18 : 1, 2, 3, 6, 9, 18 Greatest Common Factor : 9AlgorithmSTART Step 1 -: take input as x and y lets say 3 and 21 and k as 1 Step 2 -: declare start variables as int i,num,count=1 Step 3 -: IF x

Change JButton Font Dynamically in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:26

1K+ Views

The following is an example to change JButton font dynamically:Exampleimport java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; public class SwingDemo extends JFrame {    JButton button = new JButton("Change");    int fontSize = 10;    public SwingDemo() {       setSize(500, 400);       setDefaultCloseOperation(EXIT_ON_CLOSE);       add(button);       // changing font size dynamically on button click       button.addActionListener(new ActionListener() {          public void actionPerformed(ActionEvent ev) {             button.setFont(new Font("Dialog", Font.PLAIN, ++fontSize));             button.revalidate();          }       });       setVisible(true);    }    public static void main(String[] args) {       new SwingDemo();    } }OutputClick “Change” button above to change the font:

Advertisements