1

我有微调器的这部分代码。但我得到致命的错误。这里有什么问题?谢谢!我的活动扩展了 FragmentActivity。

                Spinner spinner;
                String[] layers = {getString(R.string.a), getString(R.string.b), getString(R.string.c)};

                LayoutInflater li = LayoutInflater.from(this);
                View v;
                v  = li.inflate(R.layout.nearest, null);

                ArrayAdapter<String> adapter = new ArrayAdapter<String>(MyActivity.this, android.R.layout.simple_spinner_item, layers);
                spinner = (Spinner) findViewById(R.id.spinner_nearest);
                spinner.setAdapter(adapter);


                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setView(v);

                builder.setCancelable(true);
                AlertDialog alert = builder.create();
                alert.show();}
4

1 回答 1

2

你的微调器在nearest.xml吗?

然后改为

spinner = (Spinner) v.findViewById(R.id.spinner_nearest);
于 2013-02-22T10:08:14.050 回答