Archive | ANDROID

RSS feed for this section

Android Lesson 9: android.os.Bundle

We learn about android.os.Bundle by using some simple examples: Example 1: Step 1: create new project Target android device Add an activity to mobile: Customize the activity: choose activity name: MainActivity -> Finish Here’s the structure of project when finish: Step 2: Create the layout of the activity MainActivity File res\layout\activity_main.xml Step 3: Create the […]

Read full story Comments { 0 }

Android Lesson 8 part 2: work with Spinner and custom ArrayAdapter

We can use custom ArrayAdapter with Spinner: Step 1: create new project Step 2: create new drawable resource res\drawable\logots.png Use this file for example: Step 3: create new layout resource res\layout\item.xml Step 4: Edit file res\layout\item.xml Step 5: With MainActivity.java Create custom adapter class Step 6: set customer adapter for spinner Here’s the full code […]

Read full story Comments { 0 }

Android Lesson 8: Work with Spinner

To learn about Spinner, we create a simple example for Spinner. Step 1: create new project Step 2: with file content_main.xml Create a Spinner: Step 3: file MainActivity.java Step 4: Final, run for test Explanation: android.R.layout.simple_spinner_item: an Android internal layout view android.R.id.text1 : In android.R.layout.simple_spinner_item already defined text fields: android.R.layout.simple_spinner_dropdown_item: an Android internal layout view

Read full story Comments { 0 }

Android Lesson 7 – part 3: work with ListView

We can cache view lookup for improve performance, here’s the solution: View lookup cache: The custom ArrayAdapter Here’s the full code of file MainActivity.java The result we get:

Read full story Comments { 0 }

Android Lesson 7 – part 2: work with ListView using a custom ArrayAdapter

In the previous tutorial, we learn how to use ListView using a basic ArrayAdapter. Now we learn how to use ListView using a custom ArrayAdapter. Step 1: create new project Step 2: Define new Model In file MainActivity.java Step 3: create new layout xml file res\layout\item.xml. We create 3 TextView: Step 4: Define the custom […]

Read full story Comments { 0 }

Android Lesson 7: work with ListView

To learn about ListView, we create some simple examples for ListView. Example 1: Simple ListView Step 1: create new project Step 2: File content_main.xml Add a ListView: Step 3: file MainActivity.java Explanation: android.R.layout.simple_list_item_1: an Android internal layout view android.R.id.text1 : In android.R.layout.simple_list_item_1 already defined text fields: Step 4: Run Example 2: use android.R.layout.simple_list_item_single_choice Example 3: […]

Read full story Comments { 1 }

Android Lesson 6: TelephonyManager

We learn about android.telephony.TelephonyManager by creating a simple example: Step 1: Create a new project Step 2: with file main_activity.xml add some TextView and Button: Step 3: With file MainActivity.java Step 4: file AndroidManifest.xml add Step 5: run, and we get the result: So, we can get service provider name, network operator name, phone manufacturer […]

Read full story Comments { 0 }

Android Lesson 5: android.os.Handler

We learn about android.os.Handler by creating some simple examples. Example 1: Simple counter Step 1: create new project Step 2: with file contain_main.xml add two TextView Step 3: with file MainActivity.java In class MainActivity: Step 4: run, and we get the result: So, with Handler and Runnable, we can make a simple counter.

Read full story Comments { 1 }

Android Lesson 4: File manipulation

We create some examples for learn how to manipulate files with Android. Example 1: Work with internal storage Step 1: create new project Step 2: Edit file content_main.xml Create some textviews and buttons, add the code: Step 3: Edit file MainActivity.java: Edit class MainActivity: Now, we can test this application. Step 4: Run app Conclusion […]

Read full story Comments { 0 }

Android: Get user’s current location using GPS

Step 1: create new project Step 2: In file AndroidManifest.xml After line: Add: Step 3: right click com.example.myapplication -> New -> Java Class with name GPS Step 4: in file content_main.xml add Step 5: in file MainActivity.java After line public class MainActivity extends AppCompatActivity { add in method onCreate add: Done, now you can test […]

Read full story Comments { 0 }