我希望从我的复选框中获取多个数据值 我从mysql数据库获取数据并在alertdialog上显示列表
如果选中复选框,我怎样才能获得多个数据
final ArrayList<String> selected = new ArrayList<String>();
kList = new ArrayList<HashMap<String , String>>();
listView = new ListView(this);
**if (checkBox.isChecked()){
fas = ((CheckBox) findViewById(R.id.checkBox)).getText().toString();
Toast.makeText(PasangActivity.this,fas,Toast.LENGTH_SHORT).show();
//selected.add(fas);
}** I have tried using this but its useless ...................
Log.e("SELECTED",""+selected);
new detailFasilitas().execute();
final AlertDialog.Builder builder = new AlertDialog.Builder(PasangActivity.this);
builder.setView(null).setMessage(null);
builder.setCancelable(true);
builder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.setNegativeButton("batal", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.setView(listView);
dialog = builder.create();
Toast.makeText(getApplicationContext(),"" + listView.getCount() ,Toast.LENGTH_LONG).show();
dialog.show();
这是我的asynctask
class detailFasilitas extends AsyncTask<String , String, String >{
@Override
protected String doInBackground(String... args) {
List<NameValuePair> params = new ArrayList<NameValuePair>();
JSONObject json = jsonParser.makeHttpRequest(DATA_URL_FASILITAS,"GET",params);
Log.e("Semua Data Fasilitas:",json.toString());
try{
int sukses = json.getInt(TAG_SUKSES);
if (sukses == 1){
JSONArray kateg = json.getJSONArray(TAG_DATA);
for (int x = 0; x<kateg.length();x++){
JSONObject c = kateg.getJSONObject(x);
String idfas = c.getString(TAG_ID);
String fas = c.getString(TAG_FASILITAS);
HashMap<String,String> map = new HashMap<String, String>();
map.put(TAG_ID,idfas);
map.put(TAG_FASILITAS,fas);
kList.add(map);
}
Log.e("hmmmm",""+kList);
}else{
}
}catch (JSONException e){
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url){
runOnUiThread(new Runnable() {
@Override
public void run() {
ListAdapter adapter = new SimpleAdapter(PasangActivity.this,kList,R.layout.list_check,new String[]{TAG_ID,TAG_FASILITAS},new int[]{R.id.txtid,R.id.checkBox});
setListAdapter(adapter);
}
});
}
}
我对这个问题还很新。所以请帮助我解决问题...