I have ExpandleListView
with each item having its own layout. This layout has Editexts
, checkbox
, etc. I need to capture what is typed and selected in every expandle listview
item. Has anyone used this approach?
Adapter
public class AneurismaTratamentoAdapter extends BaseExpandableListAdapter {
private List<String> lstGrupos;
private HashMap<String, List<String>> lstItensGrupos;
private Context context;
private String aneurismaTratamentoEntity;
private ArrayList<EditText> listaEditiText = new ArrayList<EditText>();
private ItemSuporte holder = null;
public List<ItemSuporte> listaHolder = new ArrayList<>();
public AneurismaTratamentoAdapter(Context context, List<String> grupos) {
this.context = context;
lstGrupos = grupos;
}
@Override
public int getGroupCount() {
return lstGrupos.size();
}
@Override
public int getChildrenCount(int groupPosition) {
return lstGrupos.size();
}
@Override
public Object getGroup(int groupPosition) {
return lstGrupos.get(groupPosition);
}
@Override
public Object getChild(int groupPosition, int childPosition) {
return lstGrupos.get(childPosition);
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.adapter_item_group_aneurisma, null);
}
else{
convertView.getTag();
}
ImageView image = (ImageView) convertView.findViewById(R.id.im_icon_list);
if(groupPosition == 0 || groupPosition > 0){
int iamgeResourceId = isExpanded ? R.mipmap.ic_seta_up_preto : R.mipmap.ic_seta_down_preto;
image.setImageResource(iamgeResourceId) ;
image.setVisibility(View.VISIBLE);
}
else{
image.setVisibility(View.INVISIBLE);
}
TextView tvGrupo = (TextView) convertView.findViewById(R.id.ed_item_menu_paciente);
tvGrupo.setText((String) getGroup(groupPosition));
return convertView;
}
@Override
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
final ItemSuporte holder;
if(convertView == null){
convertView = LayoutInflater.from(context).inflate(R.layout.adapter_aneurisma,null);
holder = new ItemSuporte();
holder.aneurismaLargura = (EditText) convertView.findViewById(R.id.et_largura);
holder.aneurismaComprimento = (EditText) convertView.findViewById(R.id.ed_comprimento);
holder.containner = (View) convertView.findViewById(R.id.container);
convertView.setTag(holder);
}
else{
holder = (ItemSuporte) convertView.getTag();
}
// Passar os parâmtros aqui caso tenha que preencher.
return convertView;
}
public void clickButtonVerFotosAneurisma(final ItemSuporte holder){
if(holder != null){
holder.bt_ver_fotos.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
irTelaImagensAneurisma();
}
});
}
}
public void clickButtonEnviarFotoAneurisma(final ItemSuporte holder){
if(holder != null){
holder.bt_enviar_foto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
irTelaEnviarFoto();
}
});
}
}
public void irTelaImagensAneurisma(){
Intent it = new Intent(context, ImagensAneurismaPacienteActivity.class);
context.startActivity(it);
}
public void irTelaEnviarFoto(){
}
private class ItemSuporte {
EditText aneurismaLargura;
EditText aneurismaComprimento;
Button bt_ver_fotos;
Button bt_enviar_foto;
View containner;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}