问题描述
我有一个活动组,其中包含3个活动.当按下按钮时,我进入此活动组并显示第一个活动.从第一项活动中,我可以进入第二项活动,从第二项活动中,我可以进入第三项活动.
I have an activity group containing 3 activities. When a button is pressed, I enter into this activity group and show the 1st activity. From the 1st activity I can goto 2nd activity and from 2nd activity I can goto 3rd activity.
在第3个活动布局中,我有一个微调框.问题是我无法单击该微调器.错误显示如下:
I have a spinner in this 3rd activity layout. Problem is I am not able to click on that spinner. Error gets displayed showing:
12-31 11:29:41.082: ERROR/AndroidRuntime(474): android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@43791b18 is not valid; is your activity running?
如何解决此问题?任何人都可以帮忙...
How can I solve this issue? Can anyone plz help...
请找到附带的微调器代码:
Please find the code for spinner attached:
setContentView(R.layout.requestinfo);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
PGDealerInfoRequestActivity.this, R.array.request_options, android.R.layout.simple_spinner_item);
spinner.setAdapter(adapter);
在requestinfo.xml内部,
Inside requestinfo.xml,
<Spinner android:id="@+id/spinner" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="@android:color/darker_gray"
android:textSize="12sp" android:textStyle="bold"
android:layout_marginLeft="10dp" android:layout_marginTop="8dp" />
推荐答案
该错误与setContentView有关.我给了
The error was with the setContentView.I had given
setContentView(R.layout.mylayout);
相反,我们应该给予
View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.mylayout, null);
this.setContentView(viewToLoad);
微调器代码为:
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.request_options, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
spinner.setAdapter(adapter);
这篇关于将微调框放入活动组时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!