Found 1957 Articles for Mobile Development

Can I change the size of UIActivityIndicator in Swift?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24
It is possible to change the size of UIActivityIndicator in swift using some tricks but it’s not recommended to change the size. To change the size of activity indicator let’s first add an indicator on an empty screen and see how it looks. For this example, I’ll also change the color to red.Let’s see how it looks when we run it without changing the size of the indicator.Now, we’ll create an outlet of activity indicator in our view controller and in the viewDidLoad method of this class we’ll add the code below.We’ll use CGAffineTransform to change the scale of our ... Read More

Check if string contains another string in Swift

Samual Sam
Updated on 30-Jul-2019 22:30:24
To check if a string contains another string in swift, we’ll need two different strings. One string that we have to check if it consists another string.Let us say the string we want to check is “point” and the whole string is “TutorialsPoint” and another string is “one two three”. Let’s check with both these string in the playground.We can do this in two ways as shown below. Let’s start by creating three different strings.var CompleteStr1 = "Tutorials point" var completeStr2 = "one two three" var stringToCheck = "point"Method OneIn this method we’ll use the .contains method of Strings to ... Read More

How to set target and action for UIBarButtonItem at runtime?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:24
To create a bar button action at run time we’ll need to go through a few steps. First of all let’s start by creating a new project.Once you have created the project, go to it’s storyboard directly, select the ViewController and Embed it into a navigation controller.Now go to the respective View controller class and inside it, we’ll perform some steps that will add a button to the navigation bar on run time.Create an objc function that should be called when the button is pressed.@objc func barButtonAction() {    print("Button pressed") }Now add the viewWillLayoutSubviews method to your class.First, we’ll ... Read More

Push segue from UITableViewCell to ViewController in Swift

Samual Sam
Updated on 30-Jun-2020 05:50:40
To create a segue from a UITableViewCell to another View controller, we’ll do it like any other ViewController to ViewController segue. We’ll do this with help of an example here.First Create a project, delete the View Controller from storyboard and add One Table View Controller and one View Controller in the storyboard.There will be one prototype cell in the Table View Controller by default. Click on it, go to its attribute inspector and give it “cell” as Identifier.Now from the prototype cell, press control and drag to the Second View Controller and select show from there.The storyboard should look like ... Read More

How to switch between hide and view password in Android

George John
Updated on 30-Jul-2019 22:30:24
There are so many cases, it required to show password while entering password or after entered password. This example demonstrate about How to switch between hide and view password.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 to res/layout/activity_main.xml.                                                 In the above code we have given two TextInputEditText ... Read More

How to Stop EditText from gaining focus at Activity startup in Android

Ankith Reddy
Updated on 30-Jul-2019 22:30:24
There are so many situations where we don't required keyboard visibility when activity starts. This example demonstrate about how to Stop EditText from gaining focus at Activity startupStep 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 given on Edit Text. By Default it contains request focus.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.EditText; public class MainActivity extends ... Read More

How to make Two activities with different colored status bar in Android.

Arjun Thakur
Updated on 30-Jul-2019 22:30:24
There are so many situations, where we need to change the different action bar colors according toproject requirement . This example demonstrate about how to make Two activities with different colored status bar.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 to res/layout/activity_main.xml.     In the above code we have created on button when you click on button it going to call second activity.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import ... Read More

How to implement Android TextInputLayout

Chandu yadav
Updated on 30-Jul-2019 22:30:24
Before getting into example, we should know what is TextInputLayout in android. TextInputLayout is extended by Linear Layout. It going to act as a wrapper for edit text and shows flatting hint animation for edit text.This example demonstrate about how to implement Android TextInputLayout.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 to res/layout/activity_main.xml.                                 In the above code ... Read More

How to get the absolute coordinates of a view in Android?

George John
Updated on 30-Jul-2019 22:30:24
Before getting into example, we should know what is absolute coordinates. It means absolute position (x, y)of a view on window manager. This example demonstrate about how to get the absolute coordinates of a view.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 to res/layout/activity_main.xml.     In the above xml, we have given one Textview. when user click on textview, it will show the position of the view on Toast.Step 3 − Add the following ... Read More

How to disable landscape mode in Android?

Ankith Reddy
Updated on 30-Jul-2019 22:30:24
Android supports two orientations as portrait and landscape. we can disable orientation in android application. This example demonstrate about how to disable landscape mode in Android.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 to res/layout/activity_main.xml.     In the above code, it contains linear layout and editext. it going to support both landscape and portrait as shown below -The above output indicates about landscape modeThe above output indicates about portrait mode.To disable landscape mode need ... Read More
Advertisements