By Resourcepool
A layout that organizes its children into a single horizontal or vertical row
Enables you to specify the location of child objects relative to each other or to the parent
The goal of this exercise is to build the login page. The first step is to create the view. View are generated with layouts, try to use them to reach the following screen. The view contains two edit text, a header and a validation button.
TextView to display a simple text
EditText allows the user to write a text
ScrollView to scroll the contents
Button guess what, a button
The best way to start with layout is to add background color to layouts, it will help you with margin, padding... To do so use :
android:background="#ttrrggbb"
tt : from 00 to FF for transparency
Try recreate the previous exercise, but this time using ConstraintLayout
The objective of this exercise is to understand the states of the activity. We are going to use Android API to log those events.
Log.i(TAG, "onCreate!");
A common practice is to add a TAG to the class for all logs.
public class ParlezVousActivity extends Activity {
private final String TAG = ParlezVousActivity.class.getSimpleName();
Override the following methods and add some explicit logs :
onCreate, onDestroy, onPause, onResume, onSaveInstanceState, onRestoreInstanceState
What happens when:
You start the application,
You receive a call,
You change your phone orientation (Ctrl+F11 for the emulator),
You close the app ?
It's now time to listen and handle the view from the activity. We are going to add some behavior in our login page. In the onCreate method of the activity, recover the objects of the view you want to manipulate. Use the findViewById() method:
private EditText usernameField;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
usernameField = (EditText) findViewById(R.id.username_field);
Add a listener on the buttons, it can either be in or outside of the class. Implement the "Clear" button and the "Send" button, when the send button is clicked show a toast.
Toast.makeText(this, "Toast !", Toast.LENGTH_SHORT).show();
Add some validation on the fly or at the button click. Check that the fields aren't empty and the password is at least 3 characters. To display the error, use a classic TextView and chagne its visibility.
setVisibility(View.VISIBLE);
If you still have time you can start to use Butter Knife, a cool way to load view and catch user interactions.
The objective of the exercise is to send our previous form to a REST web service.
First thing first, we need to add the internet permission.
Do you remember where ?
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
Create the LoginTask that extends android.os.AsyncTask.
In the onPreExecute method, display a loading wheel.
In the onPostExecute method, hide the loading wheel.
In the doInBackground method, execute your network call
Use the following url:
https://training.loicortola.com/chat-rest/1.0/connect/nico/nico
The HTTP method to use is: GET
Status 200-OK JSON response {"status":200,"message":"Login
successful"} if everything went well.
Status 401-UNAUTHORIZED JSON response
{"status":401,"message":"...","elements":"..."} if login or/and password provided are not correct
How would you build a list ?
What happens if you have more than 4000 elements ?
So how is it done ?
repositories {
mavenCentral() // jcenter() works as well because it pulls from Maven Central
}
dependencies {
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:19.1.0'
}
Glide.with(this).load("http://goo.gl/gEgYUd").into(imageView);
PhoneGap is a distribution of Apache Cordova. You can think of Apache Cordova as the engine that powers PhoneGap.
It provides mobile apps with HTML, CSS & JS, target multiple platforms with one code base, Free and open source
Titanium is not an attempt at “write once, run everywhere”.
There is a core of mobile development APIs which can be normalized across platforms. These areas
should be targeted for code reuse.
There are platform-specific APIs, UI conventions, and features which developers should incorporate
when developing for that platform.
Build native apps for multiple platforms on a shared C# codebase and add native code.