ScrollView 卡住,直到调用 onConfigurationChaged()
正如标题所示,我有一个 ScrollView,它不会滚动,直到我将设备从纵向切换到横向或横向切换到纵向以触发 Activity 的 onConfigurationChanged()
事件。
我已经在 Nexus S (2.3.3) 和模拟器 (4.0.3) 上尝试了 Activity,它显示了相同的奇怪行为。
我也尝试过将布局应用于活动,但仍然没有运气。
我的 Activity 的 XML 布局可以在 此处 找到(它有点长,我不想弄乱我的XML 问题)。
这里有一些代码可能与你们相关,可以帮助我解决这个问题:
/** {@inheritDoc} */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.terms_and_agreements);
//fire up the AsyncTask to get data
showLoadingProgress();
mBookingInfoTask = new BookingInfoTask();
mBookingInfoTask.execute();
}
/** {@inheritDoc} */
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
/** This methode is called when the BookingInfoTask has finished collecting date from the server */
public void onBookingInfoResult(String clubTerms, String portalTerms) {
final String fClubTerms = clubTerms;
final String fPortalTerms = portalTerms;
runOnUiThread(new Runnable() {
public void run() {
TextView tvTerms = (TextView) findViewById(R.id.tvTerms);
tvTerms.setText(fClubTerms + "\n\n" + fPortalTerms);
}
});
hideProgress(); //Hides progress bar
}
最后这是我的 Activity 的清单声明:
<activity
android:name=".ConfirmationActivity"
android:configChanges="keyboardHidden|orientation"
android:theme="@android:style/Theme.NoTitleBar" />
Like the title indicates, I have a ScrollView that doesn't scroll until I switch the device from portrait to landscape or landscape to portrait in order to trigger the onConfigurationChanged()
event of my Activity.
I've tried the Activity on my Nexus S (2.3.3) and the Emulator (4.0.3) and it displays the same weird behavior.
I've also tried playing around with when the layout is applied to the Activity, still no luck.
My XML Layout for the Activity can be found here (It's slightly long, and I didn't want to clutter up my question with XML) .
Here's some code that might be relevant for you guys to look at in order to help me out:
/** {@inheritDoc} */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.terms_and_agreements);
//fire up the AsyncTask to get data
showLoadingProgress();
mBookingInfoTask = new BookingInfoTask();
mBookingInfoTask.execute();
}
/** {@inheritDoc} */
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
/** This methode is called when the BookingInfoTask has finished collecting date from the server */
public void onBookingInfoResult(String clubTerms, String portalTerms) {
final String fClubTerms = clubTerms;
final String fPortalTerms = portalTerms;
runOnUiThread(new Runnable() {
public void run() {
TextView tvTerms = (TextView) findViewById(R.id.tvTerms);
tvTerms.setText(fClubTerms + "\n\n" + fPortalTerms);
}
});
hideProgress(); //Hides progress bar
}
And finally here's my Activity's Manifest declaration :
<activity
android:name=".ConfirmationActivity"
android:configChanges="keyboardHidden|orientation"
android:theme="@android:style/Theme.NoTitleBar" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过将我的 TextView (应该填充父级)包装在线性布局中来使其工作,如下所示:
这是当我无法让它滚动时的情况:
现在它像应该那样滚动了!
I got it to work by wrapping my TextView (which was supposed to fill the parent) in a Linear Layout like so:
Here's how it was when I couldn't get it to scroll:
And now it's scrolling like it should!