Posts

Showing posts with the label Button

Adding Floating Action Button (Kotlin)

Image
The  Floating Action Button (FAB)  is a circular button that triggers primary action in your app's  UI . This tutorial shows you how to add the FAB to your layout, customize some of its appearance, and respond to the button taps. We will show  Snackbar  on  FAB  click. We will use  Kotlin  and  Android Studio . Minimum API: Android 2.1 is API level 7 Step 1:  Create a new project   OR   Open your project Step 2:  Add design library in build.gradle(Module:app) under dependencies{...} implementation 'com.android.support:design:27.1.0' Step 3:  Place an image in res>drawable folder Step 4: Code activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:app= "http://schemas.android.com/apk/res-auto" xmlns:tools= "http://schemas.android.com/tools" android:layout_width= "match_parent" ...

Adding Floating Action Button (Java)

Image
The Floating Action Button (FAB) is a circular button that triggers primary action in your app's UI . This tutorial shows you how to add the FAB to your layout, customize some of its appearance, and respond to the button taps. We will show Snackbar  on FAB click. We will use Java and Android Studio . Minimum API:  Android 2.1 is API level 7 Step 1:  Create a new project   OR   Open your project Step 2: Add design library in build.gradle(Module:app) under dependencies{...} implementation 'com.android.support:design:27.1.0' Step 3:  Place an image in res>drawable folder Step 4: Code activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:app= "http://schemas.android.com/apk/res-auto" xmlns:tools= "http://schemas.android.com/tools" android:layout_width= "match_parent" android:layou...

How to move From one Activity to another Activity in Android Studio (Kotlin)

Image
      DESCRIPTION       In this tutorial we will learn how to open new Activity when a Button is clicked using Android Studio in Kotlin language. When button in an activity(Main Activity) is clicked the new activity(New Activity) will be opened..       VIDEO             SOURCE CODE       Step 1:  Create a new Project  or  open new project Step 2:  Create a new Activity(e.g. Empty Activity) Step 3: Code activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:app= "http://schemas.android.com/apk/res-auto" xmlns:tools= "http://schemas.android.com/tools" android:layout_width= "match_parent" android:layout_height= "match_parent" android:gravity= "center" tools:context= ".MainActivity" > <Button an...

Create a button and handle on click listener in Android Studio (Kotlin)

Image
How to create a button and handle OnClickListener in Kotlin using Android Studio?       DESCRIPTION       In this tutorial we will create a button and handle button click. We will display a Toast on the click of that button. However you can do your own functionality such as moving to some activity, opening fragment etc.       VIDEO             SOURCE CODE       Step 1:  Create a new Project  or  open new project Step 2: Code activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:app= "http://schemas.android.com/apk/res-auto" xmlns:tools= "http://schemas.android.com/tools" android:layout_width= "match_parent" android:layout_height= "match_parent" tools:context= ".MainActivity" > <Button ...

How to move From one Activity to another Activity in Android Studio

Image
In this tutorial we will learn how to open new activity when a button is clicked using android studio. When button in an activity(Main Activity) is clicked the new activity(New Activity) will be opened.. Step 1: Create a new Project of open new project: How to create a new project? Step 2: Create a new Activity(e.g. Empty Activity) Note: after clicking we will move to this activity... Step 3: activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:app= "http://schemas.android.com/apk/res-auto" xmlns:tools= "http://schemas.android.com/tools" android:layout_width= "match_parent" android:layout_height= "match_parent" android:gravity= "center" tools:context= ".MainActivity" > <Button android:id= "@+id/button" and...

Create a button and handle on click listener in Android Studio

Image
Step 1: Create a new project or open your project How to create a new project? Step 2: activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:app= "http://schemas.android.com/apk/res-auto" xmlns:tools= "http://schemas.android.com/tools" android:layout_width= "match_parent" android:layout_height= "match_parent" android:gravity= "center" tools:context= ".MainActivity" > <Button android:id= "@+id/button" android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:text= "Cick Button" /> </LinearLayout> Step2: MainActivity.java package com . blogspot . devofandroid . myapplication ; import android.support.v7.app.AppCompatActivity ; ...