gpt4 book ai didi

android - Mysql 查询(Where)与 edittext android

转载 作者:行者123 更新时间:2023-11-29 23:20:58 26 4
gpt4 key购买 nike

我有这段代码用 json 查询填充 ListView ,并且工作正常,但我想用 edittext 中编写的 where 查询填充该 View ,例如: Select * from tabla where name=(edittext).

class AsyncExecute extends AsyncTask<Void, Void, Void>{

@Override
protected Void doInBackground(Void... params) {
try {
// Llamamos al servicio web para recuperar los datos
HttpGet httpGet = new HttpGet("http://comupunt.esy.es/nombreb.php");
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response = (HttpResponse)httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
BufferedHttpEntity buffer = new BufferedHttpEntity(entity);
InputStream iStream = buffer.getContent();

String aux = "";

BufferedReader r = new BufferedReader(new InputStreamReader(iStream));
StringBuilder total = new StringBuilder();
String line;
while ((line = r.readLine()) != null) {
aux += line;
}

// Parseamos la respuesta obtenida del servidor a un objeto JSON
JSONObject jsonObject = new JSONObject(aux);
JSONArray cities = jsonObject.getJSONArray("cities");

// Recorremos el array con los elementos cities
for(int i = 0; i < cities.length(); i++) {
JSONObject city = cities.getJSONObject(i);

// Creamos el objeto City
City c = new City(city.getString("name"),
city.getInt("nametwo"),city.getString("posicion") );
c.setData(city.getString("photo"));


listaPersonas.add(c.photo);
// Almacenamos el objeto en el array que hemos creado anteriormente
citiesAvaiable.add(c);

}
}
catch(Exception e) {
e.printStackTrace();
}
return null;
}

最佳答案

尝试这样的事情

String mEditText = (EditText)findViewById(R.id.edittext);
String EditTextValue = mEditText.getText.toString();

然后在where条件中传递这个EditTextValue

关于android - Mysql 查询(Where)与 edittext android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27304095/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com