我对android比较陌生。
当我单击手机上的微调器时,它会抛出此错误:
android.view.windowmanager$badtokenexception unable to add window --token null is not for an application
我的代码
List<String> list = new ArrayList<String>();
list.add("Character");
list.add("Numeric");
list.add("Email");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(CreateSteps.this,android.R.layout.simple_spinner_item, list);
LinearLayout spinnerHolder = new LinearLayout(getApplicationContext());
spinnerHolder.setOrientation(LinearLayout.HORIZONTAL);
spinnerHolder.setLayoutParams(
new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT, 1f));
final Spinner newSpinner = new Spinner(getApplicationContext());
allSpns.add(newSpinner);
newSpinner.setLayoutParams(
new Spinner.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
newSpinner.setAdapter(dataAdapter);
rAlign.addView(spinnerHolder);
spinnerHolder.setId(MY_BUTTON);
MY_BUTTON++;
spinnerHolder.addView(newSpinner);
我尝试在运行 android 2.3 的手机上实现代码。