Android TextView

Android TextView

The TextView view is used to display text to the user. This is the most basic view and one that you will frequently use when you develop Android applications.  If you need to allow users to edit the text displayed, you should use the subclass of TextView, EditText, which is discussed in the next chapter. When you create a new Android project, Android Studio always creates the content_main.xml file (located in the res/layout folder), which contains a <TextView> element: <?xml version="1.0" encoding="utf-8"?> <LinearLayout

Continue Reading

Supporting Different Devices

Supporting Different Devices

Android devices come in many shapes and sizes all around the world. With a wide range of device types, you have an opportunity to reach a huge audience with your app. In order to be as successful as possible on Android, your app needs to adapt to various device configurations. Some of the important variations that you should consider include different languages, screen sizes, and versions of the Android platform. This class teaches you how to use basic platform features

Continue Reading

Android Screen Orientation

Android Screen Orientation

The screenOrientation is the attribute of activity element. The orientation of android activity can be portrait, landscape, sensor, unspecified etc. You need to define it in the AndroidManifest.xml file. For example: <activity android:name=".MainActivity" android:label="@string/app_name" android:screenOrientation="portrait"> Value Description unspecified It is the default value. In such case, system chooses the orientation. portrait taller not wider landscape wider not taller sensor orientation is determined by the device orientation sensor. One of the key features of modern smartphones is their ability to switch

Continue Reading

Getting to Know the Android User Interface

View And ViewGroup

What You Will Learn In This Chapter The various ViewGroups you can use to layout your views How to adapt and manage changes in screen orientation How to create the UI programmatically How to listen for UI notifications In this chapter, you learn the details about creating user interface in Android, and how users interact with them. In addition, you will learn how to handle changes in screen orientation on your on your Android devices. Understanding The Components Of A

Continue Reading

Passing Data Between Activities

Passing Data Between Activities

Moving From One Activity to Another Activity Start Another Activity You can start another activity within the same application by calling startActivity(), passing it an Intent that describes the activity “class name” you want to start. An intent contains the action and optionally additional data. The data can be passed to other activity using intent putExtra() method. Intent intent = new Intent(MainActivity.this, SecondActivity.class); intent.putExtra(EXTRA_MESSAGE, message); startActivity(intent); The complete sendMessage() method. /** Called when the user clicks the Send button */ public void

Continue Reading

Moving From One Activity To Another Activity

Starting Another Activity

Starting Another Activity In this tutorial I will be discussing about switching between one activity to another activities. First Method :- In Android Studio, from the res/layout directory, edit the content_my.xml file. Add the android:id="@+id/button" attribute to the <Button> element. <Button     android:id="@+id/button" android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="@string/button_send" /> In the java/akraj.snow.test directory, open the MainActivity.java file. add the <Button> method, use findViewById() to get the Button element. Button button = (Button) findViewById(R.id.button); Add OnClickListener method. button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { } }); Second

Continue Reading

Adding Action Buttons In Toolbar

Action Buttons In Toolbar

Now we need to add some action buttons in Toolbar, Let’s open menu_main.xml located under res ⇒ menu and add the search menu item as mentioned below. <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context="akraj.snow.test.MainActivity"> <!-- Search --> <item android:id="@+id/action_search" android:icon="@drawable/ic_action_search" android:title="@string/action_search" app:showAsAction="ifRoom"/> <!-- Settings, should always be in the overflow --> <item android:id="@+id/action_settings" android:title="@string/action_settings" app:showAsAction="never"/> </menu> The app:showAsAction attribute specifies whether the action should be shown as a button on the app bar. ifRoom The action is displayed as a button if there is room

Continue Reading

Android Material Design

Android Material Design

In this tutorial we are going to learn the basic steps of Material Design development Customize the Material Color Material Design provides set of properties to customize the Material Design Color theme. But we use five primary attributes to customize overall theme. colorPrimaryDark – This is darkest primary color of the app mainly applies to notification bar background. colorPrimary – This is the primary color of the app. This color will be applied as toolbar background. textColorPrimary – This is

Continue Reading

Building A Simple Android Application Part – 2

Android Application

After completing the previous lesson, you have an android application that shows an activity with a text field and a button. In this lesson, you’ll add some code to MainActivity that show a Toast Message when the user clicks the Submit button. Respond to the Submit Button In the java/akraj.snow.test directory, open the MainActivity.java file. Within the MainActivity class, add the <EditText> and <Button> method, use findViewById() to get the EditText and Button element. EditText editText = (EditText)findViewById(R.id.edit_message); Button button = (Button)findViewById(R.id.button); You may use OnClickListener to get results, when

Continue Reading

Building A Simple Android Application Part – 1

Android Application

Create a Layout In Android Studio, from the res/layout directory, open the content_main.xml file. Add the <LinearLayout> element. The result looks like this: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="akraj.snow.test.MainActivity" tools:showIn="@layout/activity_main"> </LinearLayout> Add a Text Field In the content_main.xml file, within the <LinearLayout> element, define an <EditText> element with the id attribute set to @+id/edit_message. Define the layout_width and layout_height attributes as wrap_content. Define a hint attribute as a string object named edit_message. The <EditText> element should

Continue Reading

Site Footer

Sliding Sidebar

Subscribe For Latest Updates

Subscribe to our newsletter to get the latest scoop right to your inbox.