我有微调器的这部分代码。但我得到致命的错误。这里有什么问题?谢谢!我的活动扩展了 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();}