Found 2041 Articles for Mobile Development

How to change the font and color on the UITextView in iOS?

Mohtashim M
Updated on 30-Aug-2019 10:50:31

2K+ Views

Changing font and color on UITextView is simple, you just need to update the .textColor and .font property on UITextView object, Here we will be seeing how to do so.So let’s get started, Open Main.storyboard and add UITextView as shown below, Create @IBOutlet of UITextView and name it, textView.    @IBOutlet var textView: UITextView!In your viewDidLoad method of ViewController.swift write below lines, textView.textColor = UIColor.cyan textView.font = UIFont(name: "Callout", size: 20)Final Code should look like, import UIKit class ViewController: UIViewController {    @IBOutlet var textView: UITextView!    override func viewDidLoad() {       super.viewDidLoad()       textView.textColor = ... Read More

How to change background color of TableView items on iOS?

Mohtashim M
Updated on 30-Aug-2019 10:43:34

2K+ Views

Changing the background color of table view items is different from changing the background color of the table view. New programmers may often confuse between these two things, In this post, we will be seeing how to change the background color of TableView items i.e. cells.So let’s get started.For changing the background color of the table view cell, you should change the contentView.backgroundColor property of the cell.Add the below code in your cellForRowAt indexPath method, cell.contentView.backgroundColor = UIColor.cyanYour method should look like something below, func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {    let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: ... Read More

How to create and use Global Variable in swift

Mohtashim M
Updated on 30-Aug-2019 10:41:04

3K+ Views

As per the Apple document – “Global variables are variables that are defined outside of any function, method, closure, or type contextBefore we learn how to create global variables, first let us understand completely what are they.Consider “W” which is inside the inner circle, can access everything which will be inside the inner circle. On the other hand, A can access everything which is inside the outer circle as well as everything inside the inner circle, so the scope of “A” is global as he can access both the circles.So a global variable can access everything inside the bigger and ... Read More

How to create EditText with rounded corners in Android?

Azhar
Updated on 03-Jul-2020 07:00:11

8K+ Views

This example demonstrates how to create EditText with rounded corners 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.     Step 3 − Create a drawable resource file and Add the following code to drawable/et_style.xml         Step 4   − Add the following code to src/MainActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       ... Read More

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

Mohtashim M
Updated on 30-Aug-2019 10:36:38

1K+ Views

Coming from Objective C- Background now we don’t need to use NSDate as Swift has defined its own struct type Date. Date bridges to the NSDate class. You can use these interchangeably in code that interacts with Objective-C APIs.To read more about Date you can check official apple docs https://developer.apple.com/documentation/foundation/dateIn this post we will be seeing how one can create date object, So let’s get started we will be using Playground for this purpose.First, we will be seeing how to get the current date and time (UTC), to get current date and time, create an object of Date, enter the ... Read More

How to display custom view in ActionBar in Android?

Azhar
Updated on 03-Jul-2020 07:01:08

603 Views

This example demonstrates how to display custom view in ActionBar 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.     Step 3 − Add the following code to res/layout/custom_action_bar.xml.                                         Step 4 − Add the following code to src/MainActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.view.View; import ... Read More

How to load and display an image in ImageView on Android App?

Azhar
Updated on 03-Jul-2020 07:01:48

3K+ Views

This example demonstrates how to load and display an image in ImageView on Android App.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.         Step 3 − Add the following code to src/MyAndroidAppActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.app.Activity; import android.os.Bundle; import android.widget.Button; import android.widget.ImageView; import android.view.View; import android.view.View.OnClickListener; public class MyAndroidAppActivity extends AppCompatActivity {    Button button;    ImageView image;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState); ... Read More

How to display Toast in Android?

Azhar
Updated on 03-Jul-2020 07:10:11

842 Views

This example demonstrates how to display Toast in Android.Step 1 − Create a new project in Android Studio, go to File rArr; New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml     Step 3 − Add the following code to src/MainActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       //Displaying Toast with Hello World message       Toast.makeText(getApplicationContext(), "Hello World", Toast.LENGTH_SHORT).show();   ... Read More

How to work with Camera in an Android App?

Azhar
Updated on 03-Jul-2020 06:39:09

304 Views

This example demonstrates how to work with Camera in an Android App.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.                 Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.view.Menu; import android.view.View; import android.widget.Button; import android.widget.ImageView; public class MainActivity extends AppCompatActivity {    private static final int CAMERA_REQUEST=1888;    ImageView imageView;    @Override   ... Read More

How to get the device’s IMEI/ESN number programmatically in android?

Azhar
Updated on 03-Jul-2020 06:41:27

3K+ Views

This example demonstrates how do I get the device’s IMEI/ESN number programmatically 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.         Step 3 − Add the following code to src/MainActivity.javaimport android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.support.annotation.NonNull; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.telephony.TelephonyManager; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    Button button;    TextView textView;    String IMEINumber;   ... Read More

Advertisements