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[];
@Override
Protected Zero Go ahead()Bundle saveInstanceState) {{
Super.Go ahead()saveInstanceState);
setContentView()R.Layout.activity_main);
Postalist = ()list View)findViewById()R.Id.Postalist);
PragatiDialogue = New Progressressialog()Main activity.this);
PragatiDialogue.Set message()“It’s loading…”);
PragatiDialogue.setProgressStyle()Progressressialog.STYLE_SPINNER);
PragatiDialogue.Display());
Stringering Request = New Stringering()Request.way.get, url, New Feedback.Listner()) {{
@Override
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));
PragatiDialogue.reject());
}
}, New Feedback.Error maker()) {{
@Override
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()) {{
@Override
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