Quando clico no Texto ou imagem vou para tela de alterar cadastro, Ao selecionar o checkbox gostaria de remover o produto da lista.
Estou com dúvida para implementar a remoção em meu customAdapter. Segue o código do customAdapter abaixo caso necessário posto outras informações.
Desde já agradeço qualquer informação, link de exemplos.
Já pesquisei bastante inclusive aqui no grupo mas sem êxito. :(
Esse aplicativo é para aprendizado infelizmente travei nessa parte.
public class MyCustomAdapter extends ArrayAdapter<Country> {
public ArrayList<Country> countryList;
private Context context;
public MyCustomAdapter(Context context, int textViewResourceId, ArrayList<Country> countryList) {
super(context, textViewResourceId, countryList);
this.context = context;
this.countryList = new ArrayList<Country>();
this.countryList.addAll(countryList);
}
private class ViewHolder {
TextView code;
CheckBox name;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
Log.v("ConvertView", String.valueOf(position));
if (convertView == null) {
LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.country_info, null);
holder = new ViewHolder();
holder.code = (TextView) convertView.findViewById(R.id.code);
holder.name = (CheckBox) convertView.findViewById(R.id.checkBox1);
convertView.setTag(holder);
holder.name.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox) v ;
Country country = (Country) cb.getTag();
Toast.makeText(context.getApplicationContext(),
"Clicked on Checkbox: " + cb.getText() +
" is " + cb.isChecked(),
Toast.LENGTH_LONG).show();
country.setSelected(cb.isChecked());
}
});
}else {
holder = (ViewHolder) convertView.getTag();
}
Country country = countryList.get(position);
holder.code.setText(" (" + country.getCode() + ")");
holder.name.setText(country.getName());
holder.name.setChecked(country.isSelected());
holder.name.setTag(country);
return convertView;
}
}
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.







0 comentários:
Postar um comentário