【发布时间】:2011-01-12 14:51:28
【问题描述】:
我的 home.class 中有一个微调器。当我点击微调器时,进程停止显示 WindowManager$BadTockenException 被捕获的异常。
我从扩展 ActivityGroup 的 main.class 调用这个 home.class。
如果我只运行 home.class,微调器将显示所有项目。但问题仅在于从 main.class 调用 home.class。
以下是我的代码。请告诉我为什么会这样。
main.class
public class main extends ActivityGroup
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent intent=new Intent(this,home.class);
View view=getLocalActivityManager().startActivity("1", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
setContentView(view);
}
}
home.class
String[] country={"Please selects","US","INDIA","UK"};
Spinner s2 = (Spinner) findViewById(R.id.spinnerCountry);
ArrayAdapter<CharSequence> adapterCountry=new ArrayAdapter(this,android.R.layout.simple_spinner_item,country);
adapterCountry.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s2.setAdapter(adapterCountry);
s2.setOnItemSelectedListener(new OnItemSelectedListener()
{
public void onItemSelected( AdapterView<?> parent, View view, int position, long id)
{
countryName=country[position];
}
public void onNothingSelected(AdapterView<?> parent)
{
countryName=country[0];
}
});
堆栈
线程 [ main](暂停(异常 WindowManager$BadTokenException))
AlertDialog(Dialog).show() 行:245
AlertDialog$Builder.show() 行:802
Spinner.performClick() 行:260
查看$PerformClick.run() 行:9080
ViewRoot(Handler).handleCallback(Message) 行:587
ViewRoot(Handler).dispatchMessage(Message) 行:92
Looper.loop() 行:123
ActivityThread.main(String[]) 行:3647
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) 行:不可用 [本机方法]
Method.invoke(Object, Object...) 行:507
ZygoteInit$MethodAndArgsCaller.run() 行:839
ZygoteInit.main(String[]) 行:597
NativeStart.main(String[]) 行:不可用 [本机方法]
谢谢……
【问题讨论】: