Showing posts with label Android Development Eclectics. Show all posts
Showing posts with label Android Development Eclectics. Show all posts

Saturday, March 18, 2017

DVM Anatomy

Dalvik Virtual Machine (DVM) Anatomy

By John Horton; Helder Vasconcelos; Raul Portales:
"After we write a program in Java for Android, we click on a button to change our code into another form that is understood by Android. This other form is called Dalvik EXecutable (DEX) code, and the transformation process is called compiling. The part of the Android system that executes (runs) our compiled DEX code is called the Dalvik Virtual Machine (DVM). The DVM itself is a piece of software written in another language that runs on a specially adapted version of the Linux operating system.


  locationManager.getLastKnownLocation(
    LocationManager.GPS_PROVIDER);

this single line of code searches for the available satellites and then communicates with them in orbit around the Earth while retrieving your precise latitude and longitude on the planet, it is easy to begin to glimpse the power and depth of the Android API in conjunction with the DVM. Even if that code does look a little challenging at the moment, imagine talking to a satellite in some other way!" [See Ref. 1]

[continued ...]

Copyright ©2017, Software Developer, All rights reserved.
See Contents

EditText Anatomy

EditText Anatomy

public class EditText extends TextView 

public class TextView extends View & implements ViewTreeObserver.OnPreDrawListener  

public class View extends Object & implements Drawable.Callback, KeyEvent.Callback, AccessibilityEventSource 

Classes Involved:

Object
Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of Object class.
View
Class View represents the basic building block for user interface controls (components). A View occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI controls; e.g., buttons, text fields, etc.
TextView
Class TextView displays text to users and optionally allows them to edit it. A TextView is a complete text editor, however, by default it is configured not to allow editing; that is why its sub-class EditText is created to configure the TextView for editing.

Interfaces Involved:

Drawable.Callback
KeyEvent.Callback
AccessibilityEventSource 
ViewTreeObserver.OnPreDrawListener



Visual Components (Controls) of EditText


Visual Components (Controls) of EditText

Visual Components (Controls) of EditText



EditText behaves differently based on the value of its inputType property. Example:

<EditText
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:inputType="textEmailAddress"
 android:ems="10"
 android:id="@+id/editText"
 android:layout_centerVertical="true"
 android:layout_centerHorizontal="true" />





Note 1: Property inputType is provided for EditText from public interface InputType as in android.text.InputType.

Note 2: All EditText controls are subclasses of TextView:

All EditText controls are subclasses of TextView
All EditText controls are subclasses of TextView

How to Create EditText with Rounded Corners?

Step 1: Create an object (a resource) from class Drawable to specify how EditText must be drawn:

<?xml version="1.0" encoding="utf-8"?>
<!-- res/drawable/edittext_rounded.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" android:padding="10dp">
 <solid android:color="#ffffff"/>
 <corners
 android:bottomRightRadius="20dp"
 android:bottomLeftRadius="20dp"
 android:topLeftRadius="20dp"
 android:topRightRadius="20dp"/>
</shape>

Step 2: Refer to the above resource in the layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<EditText 
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:padding="10dip"
 android:background="@drawable/edittext_rounded" />
</LinearLayout>


[continued …]




Copyright ©2017, Software Developer, All rights reserved.
See Contents