php
where is the php code and the connection to database
RequestQueue r; //this line creates a RequestQueue Object. r= Volley.newRequestQueue(this); //initialize the RequestQueue.
@Override public void onResponse(JSONArray response) { } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { } } );
JSONArray books=response; for(int i=0;i<books.length();i++) //create list of JSONObjects from the JSONArray { try { JSONObject book = books.getJSONObject(i); txt.append(bookname+ "costs " + price+"\n"); //update output } { }
r.add(jo); //add the request into the queue.
StartPage.java package tutorials.microfusionsmartsolutions.com.volleytest; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.Button; import android.widget.TextView; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonArrayRequest; import com.android.volley.toolbox.Volley; import org.json.JSONArray; import org.json.JSONObject; public class StartPage extends AppCompatActivity { Button but; TextView txt; RequestQueue r; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_start_page); txt=(TextView) findViewById(R.id.textView); r= Volley.newRequestQueue(this); @Override public void onResponse(JSONArray response) { JSONArray books=response; for(int i=0;i<books.length();i++) { try { JSONObject book = books.getJSONObject(i); txt.append(bookname+ "costs " + price+"\n"); } { } } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { } } ); r.add(jo); } }
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="tutorials.microfusionsmartsolutions.com.volleytest.StartPage"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="GET" android:id="@+id/button" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" android:id="@+id/textView" android:layout_below="@+id/button" android:layout_marginTop="10dp" android:textSize="25dp" android:layout_alignParentEnd="true" android:layout_alignParentBottom="true" android:layout_alignParentStart="true" /> </RelativeLayout>
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.