Found 2041 Articles for Mobile Development

What is the equivalent of Java static methods in Kotlin?

Soumak De
Updated on 27-Oct-2021 08:22:43

342 Views

In Java, "static" keyword is used for efficient memory management. Once a variable or method is declared as static, then the JVM will allocate memory for these variable only once. Usually static variables are used to declare common properties of a class, for example, "Name of the institution". In the following example, we will see how to use the static keyword.Example of Static in using JavaIn order to demonstrate how static works in Java, we will access our online Java compiler and we will create a Test class. Inside Test, we will try to create a static variable along with ... Read More

Throw Custom Exception in Kotlin

Soumak De
Updated on 27-Oct-2021 07:56:24

869 Views

Exception is an important aspect of any programming language. It prevents our code from generating incorrect output at runtime.The concept of exception in Kotlin is very much same as it is in Java. All the exceptions in Kotlin are the descendants of Throwable class. In Kotlin, developers do have the privilege to create their own custom Exception.Custom Exceptions are a part of unchecked exceptions which means they will be thrown at the runtime.Before getting into custom exceptions in Kotlin, let's take a look checked and unchecked exceptions.Checked ExceptionsChecked exceptions are those which are checked at the compile time. In the ... Read More

How to iterate over a Hashmap in Kotlin?

Soumak De
Updated on 27-Oct-2021 06:22:01

2K+ Views

A Map is a collection where data is stored as a key-value pair and the corresponding key has to be unique. A HashMap is a collection class based upon MutableMap interface and it does that by implementing MutableMap interface of HashTable. Kotlin provides four types of constructor to define and manipulate HashMap.HashMap() – It is the default constructor which helps us create an empty HashMap.HashMap(initialCapacity: Int, loadFactor: Float = 0f) – It helps us create a HashMap using initial capacity; if it is not provided, then it will be ignored and it will act as default HashMap().HashMap(initialCapacity: Int) – It ... Read More

How to display Material Chip View in React Native?

Shilpa S
Updated on 01-Jul-2021 09:35:14

743 Views

To display chips in the UI, we are going to make use of React Native Paper Material Design.Install react native paper as shown below −npm install --save-dev react-native-paperThe chip component looks as follows on the UI −The basic chip component is as follows −Chip NameThe basic properties of chip are as follows −PropsDescriptionmodeThe values for mode are flat and outlined. With flat mode you will not get a border and with outlined the border for the chip will be displayed.iconThe icon to be given to the chip.selectedThe values are true/false. If true the chip will be selected.selectedColorColor to be given ... Read More

Explain the working of Animations in React Native?

Shilpa S
Updated on 01-Jul-2021 09:31:50

320 Views

React Native offers an Animation component that helps to add more interactivity to components available.The animation component can be used to animate View, Text, Image, ScrollView, FlatList and SectionList.React Native provides two types of animation −Animated APILayoutAnimationAnimated APIThe animated api helps to provide time based animation based on the input/output.In this example, we will dynamically change the width and the height of the box using animated timing api.To work with animation, import the component as shown below −import { Animated } from 'react-native'To work with Animation, we need to configure it first as shown below −The Animated.timing() function makes use ... Read More

How to show a checkbox in reactnative?

Shilpa S
Updated on 01-Jul-2021 09:28:06

3K+ Views

Checkboxes is a common component that we often use on the UI. We do have some cool ways of showing checkboxes in reactnative.The core react-native package does not have checkbox support and you need to install a package to work with it.Following package has to be installed to display checkbox −npm install --save-dev react-native-paperThe basic checkbox component is as follows −Let us now see some important properties on checkbox −PropsDescriptionstatusThe value that can be given to status are checked, unchecked and indeterminate.disabledThe value is boolean.It can be used to enable/disable the checkbox.onPressThe function that will be called when the checkbox ... Read More

How to display date and time picker in ReactNative?

Shilpa S
Updated on 01-Jul-2021 08:56:57

9K+ Views

To display date and time picker in your app you have to install a package as shown below −npm install @react-native-community/datetimepicker --saveOnce you are done installing, let us now proceed on how to display a Datepicker first.Example: DateTimePicker in ReactNativeImport the datetimepicker component first as shown below −import DateTimePicker from '@react-native-community/datetimepicker';A basic DateTimePicker component looks as follows −Here are some of the important properties of DateTimePicker.PropsDescriptionmodeDefines the type of picker you want. The options are date, time, datetime and countdown.From above options datetime and countdown are available only on iOS.displayThe values for Android are default, spinner, calendar and clock. For ... Read More

Explain ReactNative SwitchSelector Component

Shilpa S
Updated on 01-Jul-2021 08:52:48

309 Views

SwitchSelector component is similar to a radio toggle button. It allows you to select with more than 2 values.To work with SwitchSelector you have to install the package as shown below −npm i react-native-switch-selector --save-devThe basic SwitchSelector looks as follows − console.log(`value selected is : ${value}`)} />Here are some important properties of SwitchSelector −PropsDescriptionoptionsAn array with label, value and imageicon id required.initialThe initial item from the array that will be selected.valueThe switch value that will be available with onPress eventonPressThe event with callback function that will get called when the Switch is changed.fontSizeThe fontSize to be considered for the label.selectedColorThe ... Read More

How to handle the error “Text strings must be rendered within a component” in ReactNative?

Shilpa S
Updated on 01-Jul-2021 08:48:30

6K+ Views

While developing your app you can come across the error as stated above. Here is the code that gives the error −Exampleimport React from "react"; import { Image , Text, View, StyleSheet } from "react-native"; export default class App extends React.Component {    render() {       return (                                       );    } } const styles = StyleSheet.create({    container: {       paddingTop: 50,       paddingLeft: 50,    },    stretch: {       width: ... Read More

How to handle errors while working with Navigation in ReactNative?

Shilpa S
Updated on 01-Jul-2021 08:45:25

956 Views

Problem: How to handle the error “A navigator can only contain 'Screen' components as its direct children” while working with Navigation in ReactNative?SolutionWhile working on your app you may come across issues like stated above. Here will understand why such error comes up and what can be done to avoid it.Here is the code that gives us the error −ExampleApp.jsimport * as React from 'react'; import { NavigationContainer } from '@react-navigation/native'; import { createStackNavigator } from '@react-navigation/stack'; import { Button, View, Alert, Text } from 'react-native'; const Stack = createStackNavigator(); const HomePage = ({ navigation }) => {    return ... Read More

Advertisements