WordPress to Android App using WP REST API Tutorial – Android Coding by DMTechnolab

The package With.wordpressappexample;

Import Android.App.Progressressialog;

Import Android.Content.Intent;

Import Android.Support.v7.App.AppCompatActivity;

Import Android..Bundle;

Import Android.Opinion.Opinion;

Import Android.Widget.Adapter view;

Import Android.Widget.ArrayAdapter;

Import Android.Widget.list View;

Import Android.Widget.Toast;

Import With.Android.Volley.Request;

Import With.Android.Volley.request;

Import With.Android.Volley.Feedback;

Import With.Android.Volley.VolleyError;

Import With.Android.Volley.Toolbox.Stringering;

Import With.Android.Volley.Toolbox.Volley;

Import With.Google.the resurrection.Arises;

Import Java.Useful.The list;

Import Java.Useful.Map;

public class Main activity Is spread AppCompatActivity {{

String url = “http://www.thejavaprogrammer.com/wp-json/wp/v2/posts?filter[posts_per_page]= 10 more fields = id, title “;

The list The list;

Arises the resurrection;

Progressressialog PragatiDialogue;

list View Postalist;

Map<String,thing> Map Post;

Map<String,thing> MapTitle;

int Posted;

String post title[];


Protected Zero Go ahead()Bundle saveInstanceState) {{

Super.Go ahead()saveInstanceState);


Postalist = ()list View)findViewById()R.Id.Postalist);

PragatiDialogue = New Progressressialog()Main activity.this);

PragatiDialogue.Set message()“It’s loading…”);



Stringering Request = New Stringering()Request.way.get, url, New Feedback.Listner()) {{


public Zero Treason()String s) {{

the resurrection = New Arises());

The list = ()The list) the resurrection.From the judge()s, The list.class);

post title = New String[list.size()];

For()int I am=0;I am<The list.Shape());++I am){{

Map Post = ()Map<String,thing>)The list.get()I am);

MapTitle = ()Map<String, thing>) Map Post.get()“Title”);

post title[i] = ()String) MapTitle.get()“to be provided”);


Postalist.setAdapter()New ArrayAdapter()Main activity.this,Android.R.Layout.simple_list_item_1,post title));



}, New Feedback.Error maker()) {{


public Zero onErrorResponse()VolleyError VolleyError) {{

Toast.Makeup()Main activity.this, “Something went wrong”, Toast.LENGTH_LONG).Display());



request rQueue = Volley.newRequestQueue()Main activity.this);

rQueue.Add up()Request);

Postalist.setOnItemClickListener()New Adapter view.OnItemClickListener()) {{


public Zero click onItem()Adapter view<The> Parent, Opinion Opinion, int Post, long Id) {{

Map Post = ()Map<String,thing>)The list.get()Post);

Posted = ()()Double)Map Post.get()“Id”)).Intimate());

Intent is intended = New Intent()getApplicationContext()),Post.class);

is intended.son()“Id”, “”+Posted);

Beginning()is intended);





Source link

About dmtechnolab

Check Also

Simplified Coding

Android Hilt Tutorial – Injecting Dependencies with Hilt – Android Coding by DMTechnolab

You are welcome Android Hilt tutorial. I hope you all are aware of it Dependency …

Leave a Reply

Your email address will not be published. Required fields are marked *