Retrofit


 

  1. Simple Retrofit
  2. Parsing JsonArrayto ListView
  3. Passing Parameters
  4. Custom Parsing

 

1. Simple Retrofit

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new Interface, GitApi.java and add following code :

Step 5 : Open src -> package -> Create new class, GitHelper.java and add following code :

Step 6 : Open AndroidManifest.xml and add following code :

Step 7 : Open build.gradle(Module: app) and add following code :

ScreenShot:

retrofit_simple retrofit_simple2

Download SourceCode

 

 

2. Parsing JsonArray to ListView

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class, MainActivity.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

Step 6 : Open build.gradle(Module: app) and add following code :

ScreenShot:

retrofit_list retrofit_list2

Download SourceCode

 

 

3. Passing Parameters

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new class, MainActivity.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

Step 6 : Open build.gradle(Module: app) and add following code :

ScreenShot:

 retrofit_params retrofit_params2

Download SourceCode

 

 

4. Custom Parsing

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout -> Create new xml, list_item.xml and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Open src -> package -> Create new Interface, ListApi.java and add following code :

Step 6 : Open src -> package -> Create new class, HelperList.java and add following code :

Step 7 : Open src -> package -> Create new class, MainActivity.java and add following code :

Step 8 : Open AndroidManifest.xml and add following code :

Step 9 : Open build.gradle(Module: app) and add following code :

ScreenShot:

retrofit_custom retrofit_custom2

Download SourceCode