0

Well, I've tried to understand and read what could cause it but I just can't get it:

I have this somewhere in my code:



    public void ShowPopup(View v) {

        TextView txtclose;
        Button btnFollow,Vazgec;
        myDialog.setContentView(R.layout.custompopup);
        txtclose =(TextView) myDialog.findViewById(R.id.txtclose);
        txtclose.setText("X");
        btnFollow = (Button) myDialog.findViewById(R.id.btnfollow);
        Vazgec = (Button) myDialog.findViewById(R.id.vazgec);
        Vazgec.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                myDialog.dismiss();
            }
        });

        final Spinner spinner = (Spinner) findViewById(R.id.spinner);
        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                //adet=position+1;
                Toast.makeText(getBaseContext(), "Çalışır abee"+position, Toast.LENGTH_SHORT).show();

            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        myDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        myDialog.show();
    }
}

What could cause such a behavior or how can I check such a thing?

Error

emrecevik
  • 3
  • 3
  • Assuming that your `Spinner` is in the `Dialog`'s layout, you need to call `findViewById()` on `myDialog` to find it, just like you did for the `Button`s above. Also, in the future, please don't post screenshots of code, XML, or logs. Please post all text as text. – Mike M. Apr 12 '20 at 03:03
  • 1
    Thank you. It worked. I'll be careful next time. – emrecevik Apr 12 '20 at 12:26

0 Answers0