1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
public class General extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.general);
ListTiers = (ListView) findViewById(R.id.listTiers);
final SimpleAdapter mSchedule = new SimpleAdapter (this.getBaseContext(), listItem, R.layout.adaptateurgenarale,
new String[] {"Nom", "Tel", "MontantT"}, new int[] {R.id.Nom,R.id.Tel,R.id.MontantT});
ListTiers.setAdapter(mSchedule);
button = (Button) findViewById(R.id.buttonGenerale);
CheckBox1 = (CheckBox) findViewById(R.id.checkboxGenerale1);
button.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v )
{
if (CheckBox1.isChecked()) {
getData(strURL1);
//ListTiers.invalidateViews();
//ListTiers.setAdapter(mSchedule);
ListTiers.setAdapter(mSchedule1);
}
}
public static final String strURL1 = "http://10.0.2.2/etatdevente/TiersLivraisonParDate1.php";
////////////////////////////////////////////////////////////////////////////
private String getData(String returnString) {
InputStream is = null;
String result = "";
EditText txt = (EditText) findViewById(R.id.editTextGeneral1);
String cherDate = txt.getText().toString();
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("DateChercher",cherDate));
// Envoie de la commande http
// Convertion de la requête en string
// Parse les données JSON
try{
JSONArray jArray = new JSONArray(result);
for(int i=0;i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
Log.i("log_tag",", Nom: "+json_data.getString("Nom")+
", Tel: "+json_data.getString("Tel")+
", MontantT: "+json_data.getInt("MontantT")
);
map = new HashMap<String, String>();
map.put("Nom", json_data.getString("Nom").toString());
map.put("Tel", json_data.getString("Tel").toString());
map.put("MontantT", json_data.getString("MontantT").toString());
listItem.add(map); |
Partager