Changing a List View into a Dialog Box - Android


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.


package com.DatabaseTest; import; import; import; 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; import; import android.content.DialogInterface; import; 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 ("");
	//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
	BufferedReader reader = new BufferedReader(new 

	sb = new StringBuilder();
	sb.append(reader.readLine() + "\n");
	String line="0";
	while ((line = reader.readLine()) != null) {
	sb.append(line + "\n");
	}catch(Exception e){
	Log.e ("log_tag", "Error converting result"+e.toString());
	//paring data
	JSONArray jArray;
	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_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) {

	ListView lv;
	lv = getListView();

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

View view,
	int position, long id) {

			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
Question Self-Answered as of 3 Years Ago
This question has already been solved: Start a new discussion instead
Start New Discussion
View similar articles that have also been tagged: