--ADVERTISEMENT--

Pacific Regmi May 23, 2019
In the previous Google Maps Android API Getting Started Tutorial: Part 1 tutorial, we had made new android project with Google Maps Activity, created a key for google map application then ran that to see the google map in our application. Google map allows you to perform lots of customization. In this tutorial, you will learn to make android app to display curse in current location using Google Map Android API V2.

Many corporate android apps make a page like contact us, about us and they display company location by highlighting actual company using google map.

Related:
Android Chrome Custom Tabs Android Tutorial with Example
YouTube Android API Integration: Getting Started with YouTube Android API
How to Get Current GPS Location Programmatically in Android

Android Example: How to Display Specific Location in Google Map using V2 API


If you are directly in this tutorial I recommend you to follow Google Maps Android API Getting Started Tutorial: Part 1 before going through this because this is continuous tutorial after that.

Android Example: How to Display Specific Location in Google Map using V2 API

In the previous tutorial we had displayed default google map in android application and here we will customize little bit and add map cursor to our location and add some text.

Open your MapsActivity.java file of Google Maps Android API project and add a line of java code mMap.setMyLocationEnabled(true); under onMapReady method. Change the line LatLng sydney = new LatLng(27.746974, 85.301582); with your location latitude and longitude. Replace 27.746974 with your latitude and 85.301582 with longitude. In this tutorial, I have used the latitude of Kathmandu, Nepal you can use your own. MapsActivity.java file will look like below.

src/MapsActivity.java

All other files are same that as previous. We don’t need to change other files to display current location in google map.

Video Demo


Now run your Get Current Location - Google Maps Android API Tutorial: Part 2 application, you will see a cursor in google map with your current location. If you click on the cursor some texts appears that we place in our java activity file.

What Next: Google Maps Android API Adding Search Bar: Part 3

Download Complete Project

You can download complete example project source code form GitHub.

Pacific Regmi May 23, 2019
In android, a SeekBar is the extension of ProgressBar. User can touch and drag to left or right to select the correct value. To control the event handling method for SeekBar you have to use seekBar.setOnSeekBarChangeListener(………….). In this tutorial, I am going to show how to use seekbar in android application. Following is the simple SeekBar example.

Related:
Android Custom SeekBar Example
Android Radio Button Example
Load Image from URL (Internet) in Android

Android Example: How to use Android SeekBar


XML Layout File

res/layout/activity_main.xml

Java Activity File

src/MainActivity.java

That’s all. Now, run your application which looks like output given below.

Output:

Android SeekBar Example
Android SeekBar

Pacific Regmi May 17, 2019
In this example, I will show how to get (display) current time in android application programmatically. To get current time in android application, we use Calendar class Calendar calendar = Calendar.getInstance();.

Related:
Get Current Date in Android Programmatically
Android Material Design with Design Support Library
Check Internet Connection in Android

Android Example: How to Get (Display) Current Time in Android Programmatically


XML Layout File
res/layout/activity_main.xml

Java Activity File
src/MainActivity.java

Now, run your application and click the Get Current Time button.

Output:

Get Current Time in Android Programmatically
Get Current Time in Android

Pacific Regmi May 17, 2019
In android, there are many layouts provided for developers. These layouts are used in almost all the android applications and each layout has different attributes. In this post, you will learn to use android linear layout, relative layout, table layout, frame layout, absolute layout and list view. Android allows you to create these layouts using xml and all the layouts file must be placed in res/layout directory.


Android Layouts Tutorial


Following are the android layouts tutorial.

1. Android Linear Layout Example

2. Android Relative Layout Example

3. Android Table Layout Example

4. Android Frame Layout Example

5. Android Absolute Layout Example

6. Simple Android ListView Example

7. Android ListView Example

8. Android Relative Layout – Views Position in Android

9. Android ScrollView Example

10. Make Rounded Corners in Android Layout

Pacific Regmi May 09, 2019
In previous Google Map Android API tutorial posts you have learned to setup google map in android app, to get current location with marker, to search in the map etc. But in this tutorial, you will learn to change the Google map types like satellite, terrain, hybrid etc using Google map android API v2.

After running this application you will see normal map. If you click the button satellite, there you see the google satellite map and if you click the button terrain, you will see terrain google map.

Prerequisite:

Google Maps Android API tutorial post becomes too longer, So, I have divided it into different part. So if you have not followed my previous google maps android api’s tutorials please go through part 1, part 2 and part 3 first.

Google Maps Android API Getting Started Tutorial: Part 1
Get Current Location - Google Maps Android API Tutorial: Part 2
Google Maps Android API Adding Search Bar: Part 3

How to Change Google Map Types in Android using Google Maps Android API V2


First open XML layout file of Google Map Android API Tutorial project and four new Buttons inside LinearLayout with onClick attributes for normal map, satellite map, terrain map and hybrid map before google map fragment. Following is the complete content of XML layout file.

res/layout/activity_maps.xml

In java activity file you need to add four methods that we add onClick attributes in our XML layout file onNormalMap, onSatelliteMap, onTerrainMap and onHybridMap. Now add mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); to show normal google map when normal button is clicked, add mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); to show google satellite map when button is clicked, add mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); to show terrain google map and mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); to show hybrid google map.

Following is the complete java code of maps activity file.

src/MapsActivity.java

How to Change Google Map Types in Android using Google Maps Android API V2

Now run your Changing Map Types - Google Maps Android API Tutorial Part 4 application and click on the buttons Normal, Satellite, Terrain and Hybrid. You will see different maps in your android application which will look like above screenshot.

Pacific Regmi May 09, 2019
In this simple tip, I am going to show how to stop activity restart when rotating/changing orientation in android device and emulator. By default in android while rotating the screen, the activity gets automatically restarted. So, following example shows you how to prevent/solved it.

Related:
How to Make Android TextView Text Selectable
How to Use Font Awesome Icons in Android Application
How to Increase the Integer Value When Screen is Touched

To stop restarting android activity you have to add a line in AndroidManifest.xml file of android project.
android:configChanges="keyboardHidden|orientation"

Android Example: How to Stop Activity Restart on Rotation


XML Layout File

res/layout/stop_restart_activity_when_rotate.xml

Java Activity File

src/StopRestartActivityWhenRotate.java

AndroidManifest.xml File

src/main/AndroidMainfest.xml

Android Example: How to Stop Activity Restart on Rotation

Now, run your Stop Activity Restart on Rotation application and type any word in edit box and rotate your device screen.

Pacific Regmi May 06, 2019
Android TextView is one of the powerful and popular UI components which is used to display texts in android application. TextView also allows us to display HTML string. So in this tutorial, you will learn to display html string inside android text view and make text of different style like heading, paragraph, lists, text style, text size, text color etc.

Displaying HTML text in android TextView is very easy. There are many ways to show html string in android textview and in this example, I will show one of the best and easy ways to display HTML string in android app.

Following example shows how to display HTML date string in android using TextView component.

Related:
How to Make Multiple Styles Inside Android TextView
How to Make Android TextView Text Selectable
Create Scrolling Text (Marquee) in Android TextView


Android Example: How to Display/Show HTML String in Android TextView


Following are the code of java file and xml layout file.

XML Layout File

res/layout/ display_html_string_in_textview.xml

Java Activity File


src/ DisplayHtmlStringAndroidTextView.java

Strings.xml File


res/values/strings.xml

 Android Example: How to Display/Show HTML String in Android TextView

Now, run your How to Display/Show HTML String in Android TextView application, you will see HTML paragraph, Headline H1, H3, list item, etc.
Powered by Blogger.