Android PHP MySql Listview Sorunu
Arkadaslar merhaba android mysql bağlantısında iki adet classım var welcome.java ve about.java... welcome.java dan çektiğim verileri about.java class ımda textviewe yazdırabiliyorum fakat amacım bu verileri listviewde göstermek.. about java clasımda bu verileri listview şeklinde göstermeyi nasıl yapabilirim yardımcı olursanız cok sevinirim..
Welcome.java
package com.example.phonebook;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.StrictMode;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Welcome extends Activity {
private ProgressDialog pDialog;
int flag=0;
JSONParser jsonParser = new JSONParser();
private static String url = "http://10.0.2.2/rdias/about.php";
private static final String veri1 = "veri1";
private static final String veri2 = "veri2";
private static final String veri3 = "veri3";
private static final String TAG_SUCCESS="success";
@Override
protected void onCreate(Bundle savedInstanceState) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads().detectDiskWrites().detectNetwork()
.penaltyLog().build());
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
}
public void action(View v)
{
if(v.getId()==R.id.w_bt1)
new loginAccess().execute();
else
Toast.makeText(this, "deneme", Toast.LENGTH_LONG).show();
}
class loginAccess extends AsyncTask<String, String, String> {
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Welcome.this);
pDialog.setMessage("Wait...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected String doInBackground(String... arg0) {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair(" "," "));
JSONObject json = jsonParser.makeHttpRequest(url,"POST", params);
Log.d("Create Response", json.toString());
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1)
{
flag=0;
String vr1=json.getString(veri1);
String vr2=json.getString(veri2);
String vr3=json.getString(veri3);
Intent i = new Intent(getApplicationContext(),About.class);
i.putExtra("veri1", vr1);
i.putExtra("veri2", vr2);
i.putExtra("veri3", vr3);
startActivity(i);
}
else
{
flag=1;
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url) {
pDialog.dismiss();
if(flag==1)
Toast.makeText(Welcome.this,"veri bulunamadı", Toast.LENGTH_LONG).show();
}
}
}
About.java
package com.example.phonebook;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class About extends ListActivity {
TextView tv;
TextView tv1;
TextView tv2;
public void onCreate(Bundle ins)
{
super.onCreate(ins);
setContentView(R.layout.about);
tv=(TextView)findViewById(R.id.a_tv);
tv1=(TextView)findViewById(R.id.textView1);
tv2=(TextView)findViewById(R.id.textView2);
Intent i=getIntent();
String vr1=i.getStringExtra("veri1");
String vr2=i.getStringExtra("veri2");
String vr3=i.getStringExtra("veri3")
System.out.println(vr1);
System.out.println(vr2);
System.out.println(vr3);
tv.setText(vr1);
tv1.setText(vr2);
tv2.setText(vr3);
}
}