Found 2041 Articles for Mobile Development

How to convert HASHMAP to JSON using GSON in Android?

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

991 Views

GSON is java library, It is used to convert OBJECT to JSON and JSON to Object. Internally it going to work based on serialization and deserialization.This example demonstrates how to convert HASHAMP to JSON using GSON library.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code in build.gradle.apply plugin: 'com.android.application' android {    compileSdkVersion 28    defaultConfig {       applicationId "com.example.andy.myapplication"       minSdkVersion 15       targetSdkVersion 28       versionCode ... Read More

How to use the apply() in Android Shared preferences with example?

Chandu yadav
Updated on 30-Jul-2019 22:30:25

387 Views

Before getting into shared preference apply(), we should know what is shared preferences in android. Using share preference, we can store or retrieve values as key and value pair. There are five different methods are available in share preference as shown below -Edit()- It going to edit shared preference valuescommit()- it going to commit shared preference values in xml fileapply()- It going to commit back changes from editor to shared preference.remove(String key)- It going to remove key and vales from shared preference use key.Put()- It going to put key and values to shared preference xml.A sample example syntax of shared ... Read More

Adding Navigation Bar programmatically iOS using Swift

Samual Sam
Updated on 30-Jul-2019 22:30:25

3K+ Views

To add navigation bar programmatically we’ll go through a series of steps that are mentioned below. We’ll be doing this in ViewWillLayoutSubviews method of our viewController.Getting the width of the current View.let width = self.view.frame.widthCreating a navigation bar with the width of our current view and height of 44 px which is the default height of a navigation bar.let navigationBar: UINavigationBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: width, height: 44))Adding the newly created navigation bar to our view.self.view.addSubview(navigationBar)We can further extend this example to add a title and a button to our View. The complete result should look something ... Read More

How to restrict UITextField to take only numbers in Swift?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

5K+ Views

In iOS apps sometimes we need to restrict our text field to take only numbers as an input, this can be done in several ways, let’s see some of them.Method 1: Changing the Text Field Type from storyboard.Select the text field that you want to restrict to numeric input.Go to its attribute inspector.Select the keyboard type and choose number pad from there.Method 2: Programmatically limiting inputs to number.Select the text fieldCreate its outlet in the view controller.Conform the view controller to UITextFieldDelegateSet the text field’s delegateAdd the following functionfunc textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool ... Read More

How to hide the status bar in a iOS App using Swift?

Samual Sam
Updated on 30-Jul-2019 22:30:25

2K+ Views

Sometimes in our application, we need to hide the status bar, navigation bar, and other things and only show the content we want to display. In this article, we’ll see how to hide the status bar in our application. To hide status bar in our iOS application using swift language we need to go through very basic steps.We can hide the status bar in two general ways. Both of these methods involve a common step.Common StepGo to Your info.plist file.Add a key called “View controller-based status bar appearance” and set its value to NO.This was a common step we’ll use ... Read More

How to get the MAC address of an iOS/iPhone programmatically?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

745 Views

In iOS versions previous to 7.0 getting the MAC address of device was possible. But with new iOS version it has been disabled for the apps to access MAC address of the device.When it is accessed or requested on current version of iOS it always returns 02:00:00:00:00:00. This has been implemented by apple because of privacy concerns. If your app needs to uniquely identify a device, apple recommends to use UDID/ UUID instead of MAC. In swift we can useUIDevice.current.identifierForVendor Which as per apple documentation says that, The value of this property is the same for apps that come from ... Read More

How do you create a date object from a date in Swift xcode in iOS?

Samual Sam
Updated on 30-Jul-2019 22:30:25

142 Views

To create a date object in swift we’ll use DateComponents() of swift. We can do this In two ways. We’ll use Playground to test our code instead of simulator.We’ll use date component and calendar to create a date. We can create date component in two ways.Method 1Creating date using the default initializer of DateComponent().var date = DateComponents.init( calendar: , timeZone: , era: , year: , month: , day: , hour: , minute: , second: , nanosecond: , weekday: , weekdayOrdinal: , quarter: , weekOfMonth: , weekOfYear: , yearForWeekOfYear: )This will ask all the things like calendar type, date, day, month, ... Read More

How to remove duplications from arraylist using treeset for listview in Android?

karthikeya Boyini
Updated on 29-Jun-2020 15:57:06

87 Views

This example demonstrate about How to remove duplications from arraylist using treeset for listview in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                                 In the above code, we have taken name as Edit text, when user click on save button it will store the data into arraylist. Click on refresh button to get the changes of listview.Step ... Read More

How to remove duplications from arraylist using linked hashset for listview in Android?

Samual Sam
Updated on 29-Jun-2020 15:55:58

94 Views

This example demonstrate about How to remove duplications from arraylist using linked hashset for listview in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                                 In the above code, we have taken name as Edit text, when user click on save button it will store the data into arraylist. Click on refresh button to get the changes of ... Read More

How to remove duplications from arraylist for listview in Android?

karthikeya Boyini
Updated on 29-Jun-2020 15:55:23

105 Views

This example demonstrate about How to remove duplications from arraylist for listview in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                                 In the above code, we have taken name as Edit text, when user click on save button it will store the data into arraylist. Click on refresh button to get the changes of listview.Step 3 − Add ... Read More

Advertisements