Using this rule, how do I delete all (Descriptions) from Listview

Asked

Viewed 30 times

1

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_especialidades);


    Integer[] imgid={
            R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white,
            R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white,
            R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white,
            R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white,
            R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white,
            R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white,
            R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white,
            R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white,
            R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white,
            R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white,
            R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white,
            R.drawable.ic_plus_white, R.drawable.ic_plus_white, R.drawable.ic_plus_white};


    String[] atividades = new String[]{"Acupuntura", "Alergia e Imunologia", "Anestesiologia",
            "Angiologia", "Angiorradiologia e Cirurgia Endovascular", "Cancerologia",
            "Cardiologia", "Cardiologia Pediátrica", "Cirurgia Cardiovascular", "Cirurgia da Cabeça e Pescoço",
            "Cirurgia do Aparelho Digestivo", "Cirurgia do Trauma", "Cirurgia Geral", "Cirurgia Pediátrica", "Cirurgia Plástica",
            "Cirurgia Torácica", "Cirurgia Vascular", "Cirurgião Dentista", "Clínica Médica", "Coloproctologia", "Dermatologia",
            "Ecocardiografia", "Eletrofisiologia Clínica Invasiva", "Endocrinologia", "Endoscopia", "Endoscopia Digestiva",
            "Ergometria", "Fisioterapeuta", "Gastroenterologia", "Gastroenterologia Pediátrica", "Genética Médica",
            "Geriatria", "Ginecologia e Obstetrícia", "Hematologia e Hemoterapia", "Hematologia e Hemoterapia Pediátrica",
            "Hemodinâmica e Cardiologia Intervencionista", "Hepatologia", "Infectologia", "Instrumentador", "Mastologia",
            "Medicina de Urgência", "Medicina Esportiva", "Medicina fetal", "Medicina Física e Reabilitação", "Medicina Intensiva",
            "Medicina Intensiva Pediátrica", "Medicina Nuclear", "Nefrologia", "Nefrologia Pediátrica", "Neurocirurgia",
            "Neurofisiologia Clínica", "Neurologia", "Neurorradiologia", "Nutrição Parenteral e Enteral", "Nutrologia",
            "Oftalmologia", "Ortopedia e Traumatologia", "Otorrinolaringologia", "Patologia", "Patologia Clínica/Medicina Laboratorial",
            "Pediatria", "Pneumologia", "Pneumologia Pediátrica", "Psiquiatria", "Radiologia e Diagnóstico por Imagem",
            "Radiologia Intervencionista e Angiorradiologia", "Reprodução Humana", "Reumatologia", "Urologia"};





    CustomListAdapter adapter = new CustomListAdapter(this, atividades, imgid);

    ListView lv = (ListView) findViewById(R.id.lv);
    lv.setAdapter(adapter);
    lv.setOnItemClickListener(chamaAtividades(this));
}

public AdapterView.OnItemClickListener chamaAtividades(final Context context){
    return (new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> av, View v, int position, long id) {

            Intent intent;
            switch(position){
                case 0:
                    intent = new Intent(context, ListaActivity.class);
                    startActivity(intent);
                    break;
                case 1:
                    intent = new Intent(context, AlergiaImunologiaActivity.class);
                    startActivity(intent);
                    break;
            }
        }
    });
}

inserir a descrição da imagem aqui

Customlistadapter:

public class Customlistadapter extends Arrayadapter {

private final Activity context;
private final String[] itemname;
private final Integer[] imgid;

public CustomListAdapter(Activity context, String[] itemname, Integer[] imgid) {
    super(context, R.layout.mylist, itemname);
    // TODO Auto-generated constructor stub

    this.context=context;
    this.itemname=itemname;
    this.imgid=imgid;
}

public View getView(int position,View view,ViewGroup parent) {
    LayoutInflater inflater=context.getLayoutInflater();
    View rowView=inflater.inflate(R.layout.mylist, null,true);

    TextView txtTitle = (TextView) rowView.findViewById(R.id.item);
    ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
    TextView extratxt = (TextView) rowView.findViewById(R.id.textView1);

    txtTitle.setText(itemname[position]);
    imageView.setImageResource(imgid[position]);
    extratxt.setText("Description "+itemname[position]);
    return rowView;

};

}

  • I think you can do that on your own if you look at the xml, that defines the list item and for the adpater.

  • This is his xml.

  • 2

    Not that one. Post the class code Customlistadapter

  • I found the problem friend Ramaral, once again thank you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.