Create Custom Dialog Box on Android

Azhar
Updated on 31-Jul-2019 07:46:12

3K+ Views

This example demonstrates about how do I create a custom message in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new projectStep 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Click res from Project → Right click on layout → Select New → Layout resource file → Name the layout = “ custom_dialog, enter Linear layout in the “Root element” and click okayStep 4 − Add the following code to custom_dialog.xml         ... Read More

Start New Activity on Click Button in Android

Azhar
Updated on 31-Jul-2019 07:34:42

22K+ Views

This example demonstrates about how do I start new Activity on click button in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new projectStep 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity {    Button button;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       button = (Button) ... Read More

Get Current Date and Time from Internet in Android

Azhar
Updated on 31-Jul-2019 07:28:32

1K+ Views

This example demonstrates about how do I get date and time from internet in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new projectStep 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.javaimport java.text.SimpleDateFormat; import java.util.Calendar; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    Calendar calendar;    SimpleDateFormat simpledateformat;    String Date;    TextView DisplayDateTime;    Button btn;    @Override    protected void ... Read More

Pass a String from One Activity to Another in Android

Azhar
Updated on 31-Jul-2019 07:15:06

323 Views

This example demonstrates about how do I pass a String from one Activity to another in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new projectStep 2 − Add the following code to res/layout/activity_main.xml.         Step 3 − Add the following code to src/MainActivity.javapackage app.com.sample; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    Button changeActivityButton;    EditText messageEditText;    @Override    protected void onCreate(Bundle savedInstanceState) {       ... Read More

Equivalent of EXCEPT in MySQL

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

4K+ Views

You cannot use EXCEPT in MySQL, instead use the NOT IN operator. Let us first create a table −mysql> create table DemoTable    (    Number1 int    ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(200); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(300); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select * from DemoTable;This will produce the following output −+---------+ | ... Read More

Preserve Select Order within MySQL UNION

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

319 Views

It’s a good choice to use CASE statement. Do not use UNION. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ShippingDate datetime    ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(ShippingDate) values('2019-04-21'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(ShippingDate) values('2019-01-01'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(ShippingDate) values('2019-05-11'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(ShippingDate) values('2018-12-31'); Query OK, 1 row ... Read More

Java File Name Should Match Public Class Name

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

18K+ Views

         In Java, the java file name should be always the same as a public class name.While writing a java program first it is saved as a ".java" file, when it is compiled it forms byte code which is a ".class" file as such that if we made our program file similar to the class it will be comfortable for us to understand without any ambiguity. We are allowed to use any name for a filename only when class is not public. In the case of a public class, we can’t use a different file name.The filename ... Read More

Create Vertical Button Column with GridLayout in Java

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

2K+ Views

To create a vertical button column, let us first create some buttons and set the layout as well −JPanel btnPanel = new JPanel(new GridLayout(10, 1, 10, 5)); btnPanel.add(new JButton("First Button")); btnPanel.add(new JButton("Second Button")); btnPanel.add(new JButton("Third Button")); btnPanel.add(new JButton("Fourth Button")); btnPanel.add(new JButton("Fifth Button")); btnPanel.add(new JButton("Sixth Button")); btnPanel.add(new JButton("Seventh Button")); btnPanel.add(new JButton("Eighth Button"));Above, we have set the GridLayout to create rows and columns with vertical and horizontal gap.The following is an example to create vertical button column with GridLayout −Examplepackage my; import java.awt.BorderLayout; import java.awt.GridBagLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; public class SwingDemo {    public static ... Read More

Title Case a Sentence in JavaScript

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

10K+ Views

Title Case a sentence in javascriptIt is nothing but converting first element of all the words in a sentence in to uppercase while the other elements remain in lowercase. The provided string(sentence) may contains a bunch of lowercase and uppercase elements. So we need an algorithm to Title Case the provided string.AlgorithmDivide all the words in the sentence individually. This task can be achieved by using string.split() method.Convert all the elements in each and every word in to lowercase using string.toLowerCase() method. Loop through first elements of all the words using for loop and convert them in to uppercase. After converting, ... Read More

8085 Program to Take All Numbers in Range 3CH and 64H in an Array

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

311 Views

Here we will see we can take all numbers which are in range 3CH and 64H from an array using 8085.Problem StatementWrite 8085 program to take all numbers which are greater or equal to 3CH, and lesser than 64H from an array. Numbers are stored at 8001 onwards, 8000 is holding the size of array, the results will be stored from 9000.DiscussionTo solve this problem, we will take the numbers from memory. Then compare it with 3C. If the Carry flag is set, then it indicates that the number is less than 3C, so just skip it. otherwise compare it ... Read More

Advertisements