Pass a String from One Activity to Another in Android

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

341 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

334 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

326 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

Parse URL in JavaScript

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

408 Views

Parsing an URLIt is very simple to parse an URL in javascript by using DOM method rather than Regular expressions. If regular expressions are used then code will be much more complicated. In DOM method just a function call will return the parsed URL. In the following example, initially a function is created and then an anchor tag "a" is created inside it using a DOM method. Later on the provided URL was assigned to the anchor tag using href. Now, when function returns the parts of the URL, it tries to return the parsed parts as shown in the output. ... Read More

Search Character or Substring in Java

Narasimha Murthi
Updated on 30-Jul-2019 22:30:26

273 Views

You can search for a particular letter in a string using the indexOf() method of the String class. This method which returns a position index of a word within the string if found. Otherwise it returns -1.Example Live Demopublic class Test {    public static void main(String args[]){       String str = new String("hi welcome to Tutorialspoint");       int index = str.indexOf('w');       System.out.println("Index of the letter w :: "+index);    } }OutputIndex of the letter w :: 3

Get Highest Value from a Single Row with Multiple Columns in MySQL

Rama Giri
Updated on 30-Jul-2019 22:30:26

254 Views

To get the highest value, use the GREATEST() method. Let us first create a table −mysql> create table DemoTable    -> (    -> Value1 int,    -> Value2 int,    -> Value3 int    -> ); Query OK, 0 rows affected (1.29 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 600, 400); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+--------+--------+--------+ | Value1 | Value2 | Value3 | +--------+--------+--------+ | 100 | 600 | 400    | ... Read More

Advertisements