BlackStar0703 0 Newbie Poster

Basically my app obtains data from a mysql server and displays it in a list view. What I want is for data from different columns (but the same row) to be as different items in a Dialog Box. I followed a tutorial on how to connect to a mysql server in android so i'm not entirely sure how it seperates each data value and defines it individually. I've highlighted the list view part of the code, any ideas how to achieve the same sort of thing but in a dialog box?

I hope i've explained myself clearly enough.
Any ideas would be much appreciated.

Thanks.

package com.DatabaseTest;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;



import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import 

org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;



import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.net.ParseException;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class DatabasesActivity extends ListActivity 

implements OnItemClickListener ,  OnClickListener{

	int rs_id;
	String[] rs_question = null;
	String[] rs_wronganswer1 = null;
	String[] rs_wronganswer2 = null;
	String[] rs_correctanswer = null;
	@Override
	public void onCreate(Bundle savedInstanceState) 

{
	super.onCreate(savedInstanceState);
	//setContentView(R.layout.main);
	 
	      	
	String result = null;
	InputStream is = null;
	StringBuilder sb=null;
	ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
	//http post
	try{
	HttpClient httpclient = new DefaultHttpClient();
	HttpPost httppost = new HttpPost

("http://10.0.2.2/RSquestionsRAN.php");
	//httppost.setEntity(new UrlEncodedFormEntity


	HttpResponse response = httpclient.execute(httppost);
	HttpEntity entity = response.getEntity();
	is = entity.getContent();
	}catch(Exception e){
	Log.e("log_tag", "Error in http connection"+e.toString());
	}
	//convert response to string
	try{
	BufferedReader reader = new BufferedReader(new 

InputStreamReader(is,"iso-8859-1"),8);
	sb = new StringBuilder();
	sb.append(reader.readLine() + "\n");
	String line="0";
	while ((line = reader.readLine()) != null) {
	sb.append(line + "\n");
	}
	is.close();
	result=sb.toString();
	
	    
	}catch(Exception e){
	Log.e ("log_tag", "Error converting result"+e.toString());
	}
	//paring data
	JSONArray jArray;
	try{
	jArray = new JSONArray(result);
	JSONObject json_data=null;
	rs_question=new String[jArray.length()];
	for(int i=0;i<jArray.length();i++){
	json_data = jArray.getJSONObject(i);
	rs_id=json_data.getInt("ID");
	rs_question[i]=json_data.getString("Question");
	rs_wronganswer1[i] = json_data.getString("WrongAnswer1");
	rs_wronganswer2[i] = json_data.getString("WrongAnswer2");
	rs_correctanswer[i] = json_data.getString("CorrectAnswer");
	
	
	}
	
	}
	catch(JSONException e1){
	Toast.makeText(getBaseContext(), "No Data Found" ,Toast.LENGTH_LONG).show();
	} catch (ParseException e1) {
	e1.printStackTrace();
	}
	setListAdapter(new
	ArrayAdapter<String>

[B][U](this,android.R.layout.simple_list_item_1,
	rs_question));
	ListView lv;
	lv = getListView();
	lv.setTextFilterEnabled(true);
	lv.setOnItemClickListener(new 

OnItemClickListener() {
	public void onItemClick(AdapterView<?> parent, 

View view,
	int position, long id) {
		
		
			}});[/U][/B]
	
		}

			public void onItemClick

(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub
		// When clicked, show a toast with the 

TextView text; 
			
	}

	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		
	}
	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.