Category «Android Basics»

Hiding the Activity title in Android

The requestWindowFeature(Window.FEATURE_NO_TITLE) method of Activity must be called to hide the title. But, it must be coded before the setContentView method. You can also hide the title of an activity if desired (such as when you just want to display a status update to the user). To do so, use the requestWindowFeature() method and pass it the …

What is Android?

Android is a mobile operating system that is based on a modified version of Linux. It was originally developed by a startup of the same name, Android, Inc. In 2005, as part of its strategy to enter the mobile space, Google purchased Android and took over its development work (as well as its develop- ment …

AlertDialog in Android

Like a Toast,  an AlertDialog is a window that provides feedback to the user.  Unlike a  Toast that fades by itself, however, an AlertDialog shows indefinitely until it loses focus.   In addition, an AlertDialog can contain up to three buttons and a list of selectable items. A button added to an AlertDialog can be connected …

Android App Basics

Here we can take an example of GeoQuiz application will consist of an activity and a layout: • An activity is an instance of Activity, a class in the Android SDK. An activity is responsible for managing user interaction with a screen of information. You write subclasses of Activity to implement the functionality that your …

Providing Messaging for Auto in Android

Staying connected through messages is important to many drivers. Chat apps can let users know if a child need to be picked up, or if a dinner location has been changed. The Android framework enables messaging apps to extend their services into car dashboards using a standard user interface that lets drivers keep their eyes …

Creating A Layout Programmatically

The most common way to create a layout is by using an XML file, as you have seen in the examples in this chapter. However, it is also possible to create a layout programmatically, by instantiating the layout class and passing it to the addContentView method in an activity class. For instance, the following code is …

GridLayout in Android

A GridLayout is similar to a TableLayout, but the number of columns must be specified using a columnCount attribute. GridLayout example <GridLayout xmlns:android=“http://schemas.android.com/apk/res/android” android:layout_width=“wrap_content” android:layout_height=“wrap_content” android:layout_gravity=“center” android:columnCount=“3”> <!— 1st row, spanning 3 columns —> <TextView android:layout_width=“wrap_content” android:layout_height=“wrap_content” android:text=“Enter your name” android:layout_columnSpan=“3” android:textSize=“26sp” /> <!— 2nd row —> <TextView android:text=“First Name”/> <EditText android:id=”@+id/firstName” android:layout_width=“200dp” android:layout_columnSpan=“2”/> <!— …

TableLayout in Android

A TableLayout is used to arrange child views in rows and columns. The TableLayout class is a subclass of LinearLayout. To add a row in a TableLayout, use a TableRow element. A view directly added to a TableLayout (without a TableRow) will also occupy a row that spans all columns. Example of TableLayout <TableLayout xmlns:android=“http://schemas.android.com/apk/res/android” …

FrameLayout in Android

A FrameLayout positions its children on top of each other. By adjusting the margin and padding of a view, it is possible to lay out the view below another view. Example of FrameLayout <FrameLayout xmlns:android=“http://schemas.android.com/apk/res/android” xmlns:tools=“http://schemas.android.com/tools” android:orientation=“horizontal” android:layout_width=“match_parent” android:layout_height=“match_parent”> <Button android:text=“Button1” android:layout_width=“wrap_content” android:layout_height=“wrap_content” android:layout_marginTop=“100dp” android:layout_marginLeft=“100dp” /> <ImageButton android:src=”@android:drawable/btn_star_big_on” android:alpha=“0.35” android:layout_width=“wrap_content” android:layout_height=“wrap_content” android:layout_marginTop=“90dp” android:layout_marginLeft=“90dp” /> </FrameLayout> …