import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import org.apache.http.NameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class ResultPage2 extends ListActivity {
private ProgressDialog pd;
JSONParser jparser = new JSONParser();
ArrayList<HashMap<String, String>> P;
JSONArray s = null;
private static String url = "http://akosamanus.xzn.ir/getsunday.php";
TextView who,which;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result_page2);
who = (TextView)findViewById(R.id.who2);
which = (TextView)findViewById(R.id.which2);
Bundle extras = getIntent().getExtras();
String whoo = extras.getString("uname");
String whiche = extras.getString("uday");
who.setText(whoo);
which.setText(whiche);
P = new ArrayList<HashMap<String, String>>();
new result().execute();
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
String zname = ((TextView) v.findViewById(R.id.tvsetname)).getText().toString();
String zside = ((TextView) v.findViewById(R.id.tvsetside)).getText().toString();
String zstep = ((TextView) v.findViewById(R.id.tvsetstep)).getText().toString();
String zcalf = ((TextView) v.findViewById(R.id.tvsetcalf)).getText().toString();
String zjump = ((TextView) v.findViewById(R.id.tvsetjump)).getText().toString();
String zchair = ((TextView) v.findViewById(R.id.tvsetchair)).getText().toString();
Intent intent = new Intent(ResultPage2.this,CResultPage2.class);
intent.putExtra("zside",zside);
intent.putExtra("zstep",zstep);
intent.putExtra("zcalf",zcalf);
intent.putExtra("zjump",zjump);
intent.putExtra("zchair",zchair);
startActivityForResult(intent,2);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK && requestCode==2){
if(data.hasExtra("Result")){
}
}
}
class result extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pd = new ProgressDialog(ResultPage2.this);
pd.setMessage("loading...");
pd.show();
}
@Override
protected String doInBackground(String... argman) {
// ContentValues params = new ContentValues();
List<NameValuePair> params = new ArrayList<NameValuePair>(); // Building Parameters
// getting JSON string from URL
JSONObject json = jparser.makeHttpRequest(url, "GET", params);
try {
int t = json.getInt("t");
if (t==1){
s=json.getJSONArray("saturday");
for (int i=0;i<s.length();i++){
JSONObject c=s.getJSONObject(i);
String username=c.getString("username");
String userside=c.getString("userside");
String userchair=c.getString("userchair");
String userjump=c.getString("userjump");
String userstep=c.getString("userstep");
String usercalf=c.getString("usercalf");
String today=which.getText().toString();
HashMap<String,String> map=new HashMap<String,String>();
map.put("username",username);
map.put("userside",userside);
map.put("userchair",userchair);
map.put("userjump",userjump);
map.put("userstep",userstep);
map.put("usercalf", usercalf);
map.put("Saturday", today);
P.add(map);
}
}else {
Toast.makeText(ResultPage2.this, "ooooooooooops", Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
pd.dismiss();
runOnUiThread(new Ruable() {
@Override
public void run() {
ListAdapter adapter=new SimpleAdapter(ResultPage2.this,P,R.layout.item_list2,
new String[]{"username","userside","userchair","userjump","userstep","usercalf","Saturday"},
new int[]{R.id.tvsetname,R.id.tvsetside,R.id.tvsetchair,R.id.tvsetjump,R.id.tvsetstep
,R.id.tvsetcalf,R.id.tvsetday});
setListAdapter(adapter);
}
});
}
}
}
<?php
$con = mysql_coect("...","...","...");
mysql_select_db("...",$con);
$response=array();
$result=mysql_query("select * from saturday");
if(mysql_num_rows($result)>0){
$response["saturday"]=array();
while($row=mysql_fetch_array($result)){
$temp=array();
$temp["username"]=$row["user_name"];
$temp["userside"]=$row["user_sideup"];
$temp["userchair"]=$row["user_chair"];
$temp["userjump"]=$row["user_jump"];
$temp["userstep"]=$row["user_step"];
$temp["usercalf"]=$row["user_calf"];
array_push($response["saturday"],$temp);
}
$response["t"]=1;
echo json_encode($response);
}else{
$response["t"]=0;
$response["message"]="not fonud";
echo json_encode($response);
}
?>
?>
برچسب: خواندن اطلاعات از دیتابیس,خواندن اطلاعات از پورت سریال,خواندن اطلاعات کارت تلفن,خواندن اطلاعات از دیتابیس در c,خواندن اطلاعات از پورت com,خواندن اطلاعات ecu,خواندن اطلاعات از sql,خواندن اطلاعات از پورت rs232,خواندن اطلاعات از دیتابیس در php,خواندن اطلاعات از اکسل در c,
نویسنده: کاوه محمدزادگان