JavaScript Display Possibilities JavaScript can “display” data in different ways: Writing into an HTML element, using innerHTML. Writing into the HTML output using document.write(). Writing into an alert box, using window.alert(). Writing into the browser console, using console.log(). Using innerHTML To access an HTML element, JavaScript can use the document.getElementById(id) method. The id attribute defines the HTML element. The innerHTML property defines the HTML content: Example <!DOCTYPE html> <html> <body> <h1>My First Web Page</h1> <p>My First Paragraph</p> <p id="demo"></p> <script> document.getElementById("demo").innerHTML = 5 + 6; </script> </body> </html> Using document.write() For testing purposes, it is convenient to use document.write(): Example <!DOCTYPE html> <html> <body> <h1>My First Web Page</h1> <p>My first paragraph.</p>…
-
-
Before you dive deeper into Kotlin’s features, go back to DetailActivityKotlin.kt and replace the contents of the file with the following: package com.tejsumeru.android.omgandroid import android.content.Intent import android.os.Bundle import android.support.v4.view.MenuItemCompat import android.support.v7.app.AppCompatActivity import android.view.Menu import android.widget.ImageView import android.support.v7.widget.ShareActionProvider import com.squareup.picasso.Picasso class DetailActivityKotlin : AppCompatActivity() { private val imageUrlBase = "http://covers.openlibrary.org/b/id/" private var imageURL = "" private var shareActionProvider: ShareActionProvider? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_detail) actionBar?.setDisplayHomeAsUpEnabled(true) val imageView = findViewById<ImageView>(R.id.img_cover) val coverId = this.intent.extras.getString("coverID") val len = coverId?.length ?: 0 if (len > 0) { imageURL = imageUrlBase + coverId + "-L.jpg" Picasso.with(this).load(imageURL).placeholder(R.drawable.img_books_loading).into(imageView) } } private fun setShareIntent() { val…
-
Animation is a method in which a collection of images are combined in a sepecific way and processed then they appear as moving images. Building animations make on-screen objects seems to be alive. Android has quite a few tools to help you create animations with relative ease. so in this article we will learn to create animations using Kotlin. below are some attributes which we are using while writing the code in xml. Table of Attributes : XML ATTRIBUTES DESCRIPTION android:duration It is used to specify the duration of animation to run android:fromAlpha It is the starting alpha value for…
-
Kotlin KOTLIN is a cross platform, statically types, general purpose programming language with type inference. KOTLIN is designed to interoperate fully with java but type inference allows its syntax to be more concise.KOTLIN is sponsored by JetBrains and Google through the Kotlin Foundation. Java JAVA is an Object Oriented Programming Language developed by JAMES GOSLING and colleagues at SUN MICRO SYSTEMS in 1991.The language was initially called OAK. It was developed as a full fledged programming language in which one can accomplish the same sorts of tasks and solve the similar problems that one can do in other programming languages such as BASIC,C++ etc. Using Kotlin…
-
-
ALGORITHM An Algorithm is a finite set of instruction that perform a particular task. An Algorithm should satisfy following criteria. Input: Zero or more quantities are supplied externally. Output: At least one quantity is produced. Definiteness: Each instruction is clear and unambiguous. Finiteness: Algorithm must terminate after few steps. Effectiveness: Every instruction must be very basic. ANALYSIS: It means determining amount of resources (such as time and space) needed to execute it. TIME COMPLEXITY: Time complexity of an algorithm is basically the execution time of a program. Time complexity of an algorithm depends on the number of machine instruction. SPACE…
-
Linear data structure: A data structure is said to be linear if its data item form a linear sequence. Examples of the linear data structure are: (a) Array (b) Linked List (c) Stack (d) Queue Array: An array is a collection of data elements of same datatype. The elements of the array are stored in consecutive memory locations. Arrays are declared using the following syntax: type name[size]; memory representation: Stack: A stack is a linear list in which insertion and deletion operations are performed at only one end of the list. It follows LIFO structure. Queue: A queue is a…
-
String is a sequence of characters. In this guide, we will see how to declare, use and manipulate strings in Kotlin. Declare a String in Kotlin There are whole bunch of ways we can define a String in Kotlin. Lets have a look at the following example, here we have declare two immutable strings website & longString and we have also declared two mutable strings name & lName. package tejprogramming fun main(args : Array<String>){ /** * These Strings are Immutable which * means they are read-only and * unchangeable */ val website = "Tej Sumeru" /** * This is how we declare long strings */ val longString…
-
There are two types of variables – mutable and immutable. An immutable variable is one whose value cannot be changed, also known as unchangeable or read-only variable. On the other hand the value of the mutable variable can be changed. Immutable variable: val keyword Immutable variable is declared using val keyword in Kotlin. In this example, we have declared an immutable variable myName using val keyword and later displayed the value of it. package tejprogramming fun main(args : Array<String>){ /** * This is an immutable variable * also called unchangeable variable * or read-only variable. */ val myName = "Suvidha" println("My Name is: "+myName) } …
-
Data structures: A data structure is a way of organizing data items such that data items can be accessed efficiently. Or A data structure is a way of organizing data items that considers not only the items stored, but also their relationship to each other. Types of data Structure: Primitive data structure: The data structures that are directly operated by machine level instructions are known as primitive data structures. Following are the primitive data structure: (a) Integer : – Integer is a represent numbers. – The set of integer is: {…………-(n+1), -n,…,-2,-1,0,1,2,……..,n,n+1,………} (b) Real: – The number having decimal point…