Help with Spinner - Android Studio

0

Hello,

I need to make a function that changes the image of an ImageView, according to what you have selected in a spinner and with input data "height" and "area". I'm doing it this way and it's bugging when I click to run.

Thanks for the help!

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_procedimentos);

    final Spinner categorias = (Spinner)findViewById(R.id.spinner2);
     final ImageView tabela = (ImageView)findViewById(R.id.imageTabelas);
     final EditText editArea = (EditText)findViewById(R.id.editArea2);
     final  EditText editAltura = (EditText)findViewById(R.id.editAltura);
    Button btExecutar = (Button) findViewById(R.id.buttonExecutar);
    Button btVoltarInicio2 = (Button) findViewById(R.id.buttonVoltarInicio2);



    btExecutar.setOnClickListener(new View.OnClickListener() {
        private int contentView;

        public void onClick(View view) {

            Double area;
            Double altura;

            final Spinner categorias = null;

            if (editArea.getText().toString().isEmpty()){
                area = 1.00;
            }
            else{
                area = Double.parseDouble(editArea.getText().toString().trim());
            }

            if (editAltura.getText().toString().isEmpty()){
                altura = 1.00;
            }
            else{
                altura = Double.parseDouble(editAltura.getText().toString().trim());
            }


            categorias.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView <?> parent, View view, int position, long id) {
                    ImageView tabela = null;



                    if(categorias.getSelectedItem().equals("Grupo A") && altura<750 && area<500{
                        tabela.setImageResource(R.drawable.teste);
                    }
                }
            });

        }});
    
asked by anonymous 16.05.2018 / 00:52

0 answers