Right here you can see the advantage of using Retrofit. In the callback, we get the tracks returned and display the title of the first track in the list if the request was successful otherwise we display an error message to the user. We use the latter, passing it a Callback function that will be called when a response is returned. Create a class named Config and modify it as shown package com. To start off, create a class that will hold some configuration data like the client ID and base URL for the SoundCloud endpoints. You’ll need an internet connection for Gradle to fetch them. Gradle will fetch the dependencies added. Click on Sync Now to the right of that message. When you change the adle file, a message will let you know that a Sync is needed for the IDE to work correctly. I will go through why we use the libraries as we progress through the tutorial. Next open your app’s adle file and add the gson, retrofit, converter-gson and picasso libraries.Īdd the following dependencies to the file. Choose the Empty Activity template on the next screen and on the last screen click Finish. On the next screen I left the Minimum SDK at the default of API 15. Set your own company domain and click on Next.
You can find help online on how to use Eclipse.).Ĭreate a new project and name the app SPPlayer. If you’re using Eclipse, some steps taken in the tutorial will be different, for example adding libraries. Create a new Android project (I’m using Android Studio. With that set up, we’ll now create the Android app. Leave the page open as you’ll need to copy the Client ID shown into the Android app. On the next page, you’ll be shown your app’s details. On the screen that follows, name your app. Once you’ve created an account, click on the Register a New App link on the right side of that page. Import 7.app.As mentioned, we are going to create an app that accesses the SoundCloud API, so first you need to register an account on the SoundCloud Developer portal at. If person doesn’t enter the value and directly click on the any button then a Toast message will appear on the screen telling user to enter the required numbers. By default the value is String and we need to convert it into Double to perform operation over it. ParseDouble() is used to convert String value to double.
For that we use setOnClickListener() function. So for that we need to define these operation over button click. This calculator app basically perform five operations i.e addition, subtraction, multiplication, division and reset. The interface part of the application is over, let’s focus on adding functionality to the application. Step 4: Open src -> package -> MainActivity.java.
So now we have designed the complete UI of the Calculator App.
The complete interface code of activity_main.xml: Iii of Step 3 – Further in continuation with previous linearlayout add a textview, textfield(Number) for displaying result which makes the interface complete. This code will be inserted in main layout: in it and close the linearlayout.įollowing code of activity_main.xml. Ii of Step 3 – Then before closing the above layout define another layout as Linearlayout horizontal, add five button ( +, -, *, / and Clear) define their properties like id, width, height etc. I of Step 3 – Create a Linearlayout vertical, add a textview followed by two textfields Number(decimal) for writing numbers in it. Here we are going to create the application interface like add layouts, Button, TextView and EditText. Step 3: Open res -> layout -> activity_main.xml (or) main.xml. Step 2: Create a new project and name it Calculator.