public static ArrayList<Fields> getData(Context context){
RequestQueue requestQueue = Volley.newRequestQueue(context);
ArrayList<Fields> liste = new ArrayList<>();
Log.i("responseVelib", "ok");
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
(Request.Method.GET, URLVelib, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
// Log.i("Response: " , response.getJSONArray("records").get(0).toString());
JSONArray jsonArray = response.getJSONArray("records");
for(int i = 0; i < jsonArray.length(); i++){
JSONObject jsonObject = jsonArray.getJSONObject(i);
Log.i("Response: ", jsonObject.getString("fields"));
// String email = jsonObject.getString("email");
//jsonResponses.add(email);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO: Handle error
}
});
requestQueue.add(jsonObjectRequest);
return liste ;
}
min sdk version : La version minimal qu'un appareil devra avoir pour faire tourner ton application.
target sdk version : La version pour laquelle votre application à été conçu; C'est en quelque sorte la cible idéal.
compile sdk version : La version avec la quelle l'application est compilé. En général elle est égale à target sdk version.
+voici le site
http://pojo.sodhanalibrary.com/
compile 'com.squareup.okhttp3:okhttp:3.8.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'javax.mail:mail:1.4.7'
compile 'com.facebook.stetho:stetho:1.5.0'
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.ababsa.opendataws.Metier.Fields;
import java.util.ArrayList;
/**
* Created by ababsa on 24/05/2017.
*/
public class FieldAdapter extends ArrayAdapter<Fields> {
public FieldAdapter(Context context, ArrayList<Fields> fiels) {
super(context, 0, fiels);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View result = convertView;
if (convertView == null)
{
result = LayoutInflater.from(getContext()).inflate(R.layout.modele, parent, false);
}
Fields film = getItem(position);
TextView titre = (TextView)result.findViewById(R.id.Titre);
titre.setText(film.getTitre());
TextView realisateur = (TextView)result.findViewById(R.id.Realisateur);
realisateur.setText(film.getRealisateur());
ImageView imageview = (ImageView)result.findViewById(R.id.LigneImg);
//imageview.setImageResource( film.getImg());
return result;
}
public void updateData(){
this.notifyDataSetChanged();
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher"
android:id="@+id/LigneImg">
</ImageView>
<LinearLayout
android:orientation="vertical"
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:text="Titre" android:id="@+id/Titre" android:paddingLeft="15dip">
</TextView>
<TextView
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:text="Réalisateur" android:id="@+id/Realisateur" android:paddingLeft="15dip">
</TextView>
</LinearLayout>
</LinearLayout>