Get Absolute Coordinates of a View in Android

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

5K+ Views

Before getting into example, we should know what is absolute coordinates. It means absolute position (x, y)of a view on window manager. This example demonstrate about how to get the absolute coordinates of a view.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.     In the above xml, we have given one Textview. when user click on textview, it will show the position of the view on Toast.Step 3 − Add the following ... Read More

Try and Except in Python

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

783 Views

To use exception handling in python, we first need to catch the all except clauses.Python provides, “try” and “except” keywords to catch exceptions. The “try” block code will be executed statement by statement. However, if an exception occurs, the remaining “try” code will not be executed and the except clause will be executed.try:    some_statements_here except:    exception_handlingLet’s see above syntax with a very simple example − Live Demotry:    print("Hello, World!") except:    print("This is an error message!")OutputHello, World!Above is a very simple example, let’s understand the above concept with another example − Live Demoimport sys List = ['abc', 0, 2, ... Read More

Instruction Set Classification of 8085 Microprocessor

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

20K+ Views

INTEL 8085 has a very enriched Instruction Set. Varieties of instructions it can execute. All these instructions can be broadly classified as follows −DescriptionNo. of opcodesNo. of instruction typesExampleData transfer Instructions8313MOV, MVI etc.Arithmetic Instructions6214ADD, SUB etc.Logical Instructions4315AND, XOR etc.Stack Instructions159PUSH, POP etc.Branch Instructions368JMP, JZ etc.I/O Instructions22IN, OUT etc.Interrupt Instructions55RST 0, RST 1 etc.Total24666Following is the table showing the list of Control instructions with their meanings.OpcodeOperandMeaningExplanationNOPNoneNo operationNo operation is performed, i.e., the instruction is fetched and decoded only.HLTNoneHalt and enter wait stateThe CPU finishes executing the current instruction and stops further execution. An interrupt or reset is necessary to exit from ... Read More

Get a List of Non-Empty Tables in a Particular MySQL Database

Anvi Jain
Updated on 30-Jul-2019 22:30:24

645 Views

To get a list of non-empty tables in a particular MySQL database, the following is the syntax −SELECT table_type, table_name, table_schema from information_schema.tables where table_rows >= 1 and table_schema = 'yourDatabaseName';Implement the above syntax for your database. Here, our database is “test”. The query is as follows −mysql> select table_type, table_name ,table_schema from information_schema.tables −> where table_rows >= 1 and table_schema = 'test';The following is the output displaying the non-empty tables in the database “test” −+------------+------------------------------+--------------+ | TABLE_TYPE | TABLE_NAME                   | TABLE_SCHEMA | +------------+------------------------------+--------------+ | BASE TABLE | add30minutesdemo     ... Read More

Babinet's Principle: The Basis for Slot Antenna

Knowledge base
Updated on 30-Jul-2019 22:30:24

3K+ Views

Babinet’s Principle is actually the principle used in optics. According to its definition, “When the field behind a screen with an opening is added to the field of a complementary structure, the sum is equal to the field when there is no screen”The images clearly explain the principle. In all the regions, which are non-collinear with the beam, the above two screens, in figure 1 & 2, produce the same diffraction pattern.Case1Consider a light source and a conducting plane (field) with an aperture before a screen. The light does not pass through the opaque area but passes through the aperture.Case2Consider ... Read More

Implement Android TextInputLayout

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

3K+ Views

Before getting into example, we should know what is TextInputLayout in android. TextInputLayout is extended by Linear Layout. It going to act as a wrapper for edit text and shows flatting hint animation for edit text.This example demonstrate about how to implement Android TextInputLayout.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.                                 In the above code ... Read More

Using final Keyword to Prevent Overriding in Java

Jai Janardhan
Updated on 30-Jul-2019 22:30:24

2K+ Views

Method overriding can be prevented by using the final keyword with a method. In other words, a final method cannot be overridden.A program that demonstrates this is given as follows:Exampleclass A {    int a = 8;    final void print() {       System.out.println("Value of a: " + a);    } } class B extends A {    int b = 3;    void print() {       System.out.println("Value of b: " + b);    } } public class Demo { public static void main(String args[]) { B ... Read More

Add Results from Several COUNT Queries in MySQL

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

189 Views

To add results from several COUNT queries, you can use the following syntax −SELECT (SELECT COUNT(*) FROM yourTableName1)+ (SELECT COUNT(*) FROM yourTableName2)+ (SELECT COUNT(*) FROM yourTableName3)+ . . . N AS anyAliasName;Let us use three tables in the test database −userssortingstringdemouserlogintableCheck the table records from the table using a select statement. Let’s take 3 sample tables with records.The table records for the first table is as follows −mysql> select *from users;The following is the output −+----+----------+---------------------+ | Id | UserName | UserLastseen        | +----+----------+---------------------+ |  1 | Larry    | 2019-01-15 02:45:00 | |  2 | Sam ... Read More

Return Date Set to the First Millisecond of the Month After Midnight

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

182 Views

Use the getMaximum() method in Java to returns the maximum value for the given calendar field. We will use it to set the minute, second and milliseconds.Let us first declare a calendar object −Calendar dateNoon = Calendar.getInstance();Now, we will set the hour, minute, second and millisecond to the first possible millisecond of the month after midnight −// hour, minute and second calendar.set(Calendar.HOUR_OF_DAY, calendar.getMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getMaximum(Calendar.SECOND)); // millisecond calendar.set(Calendar.MILLISECOND, calendar.getMaximum(Calendar.MILLISECOND));The following is an example that return a Date set to the first possible millisecond of the month after midnight −Example Live Demoimport java.util.Calendar; import java.util.GregorianCalendar; public class Demo { ... Read More

Get Random Value Between Two Values in MySQL

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

7K+ Views

To get the random value between two values, use MySQL rand() method with floor(). The syntax is as follows.select FLOOR( RAND() * (maximumValue-minimumValue) + minimumValue) as anyVariableName;Let us check with some maximum and minimum value. The maximum value we are considering is 200 and minimum is 100. The random number will be between 100 and 200 including 100 and 200 itself.The query is as follows.mysql> select FLOOR( RAND() * (200-100) + 100) as RandomValue;The following is the output.+-------------+ | RandomValue | +-------------+ | 144 | +-------------+ 1 row in set (0.00 sec)Now ... Read More

Advertisements