list array get rondme number
I have layout infiltrator which has checkbox on every row .
I using the following code to get some text filed " Students id for each
row was checked "
and sends that to database .
but my problem when i check on student number 5 and click submit i found
that my Array-list contain number " 4 , 5 , 6 " and So on .
some time i checking on 2 then 6 i found that array has numbers ( 2
,3,4,5,6,7 ) i don't know why that array dose that .
my class code :
List<Integer> checkBoxState = new ArrayList<Integer>(50); // note here
: i want to remove this 50 but i can't
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
...........
...........
holder.checkbox
.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
holder.checkbox2.setChecked(false);
holder.checkbox3.setChecked(false);
holder.row.setBackgroundResource(R.drawable.green);
} else {
}
((Student) holder.checkbox.getTag()).setSelected(true);
if (((CheckBox) holder.checkbox).isChecked()) {
ViewGroup row1 = (ViewGroup) holder.checkbox
.getParent();
View view1 = ((ViewGroup) row1).getChildAt(4);
if (view1 instanceof TextView) {
holder.StudentId = (TextView) view1;
checkBoxState.add(Integer
.parseInt(holder.StudentId.getText()
.toString()));
}
}
}
});
sumbit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// getting each element from array list and send it to SOAP webservice
for (int i = 0; i < checkBoxState.size(); i++) {
Toast.makeText(context, checkBoxState.get(i).toString(),
Toast.LENGTH_SHORT).show();
try {
SoapObject request = new SoapObject(NAMESPACE,
METHOD_NAME);
HttpTransportSE androidHttpTransport = new
HttpTransportSE(
URL);
PropertyInfo pi = new PropertyInfo();
pi.setName("SID");
pi.setValue(checkBoxState.get(i));
pi.setType(Integer.class);
request.addProperty(pi);
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (Exception ex) {
}
}
}
});
No comments:
Post a Comment