Wie zeige ich jedes Abfrageergebnis in einer einzelnen Zeile mit JSON an?Android

Forum für diejenigen, die für Android programmieren
Guest
 Wie zeige ich jedes Abfrageergebnis in einer einzelnen Zeile mit JSON an?

Post by Guest »

Ich entwickle eine Anwendung, um Client -Bestellungen zu empfangen. Informationen werden angezeigt als: < /p>

Code: Select all

Tomato quantity 4,Strawberry quantity 6

**How to display them like :**

*Tomato quantity 4

Strawberry quantity 6*

I mean each order name with the quantity on a single line
< /code>

So erhalte ich die Informationen: < /p>


[b] Dies ist mein JSON -Code: [/b] 

public class BackgroundTask extends AsyncTask {
Context ctx;
Activity activity;
RecyclerView recyclerView;
RecyclerView.Adapter adapter;
RecyclerView.LayoutManager layoutManager;
ProgressDialog progressDialog;
ArrayListarrayList= new ArrayList();
public BackgroundTask(Context ctx)
{
this.ctx=ctx;
activity=(Activity)ctx;
}
String json_string = "\\";

@Override
protected void onPreExecute() {
recyclerView=(RecyclerView)activity.findViewById(R.id.recyclerView);
layoutManager=new LinearLayoutManager(ctx);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
adapter=new RecyclerAdapter(arrayList);
recyclerView.setAdapter(adapter);
progressDialog = new ProgressDialog(ctx);
progressDialog.setTitle("Please Wait..");
progressDialog.setMessage("List is loading..");
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(false);
progressDialog.show();
}

@Override
protected void onProgressUpdate(Order... values) {
arrayList.add(values[0]);
adapter.notifyDataSetChanged();
}

@Override
protected void onPostExecute(Void result) {
progressDialog.dismiss();

}

@Override
protected Void doInBackground(Void... params) {
try
{
URL url = new URL(json_string);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();

InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder stringBuilder = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line + "\n\t");
}

httpURLConnection.disconnect();

String json_string = stringBuilder.toString().trim();
JSONObject jsonObject = new JSONObject(json_string);
JSONArray jsonArray = jsonObject.getJSONArray("server_response");
int count=0;
while(count

 Mein PHP -Code < /strong>: < /p>


Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post