2012-02-03 33 views
0

像標題所示,我有一個滾動視圖不會滾動,直到我將設備從縱向切換到橫向或橫向到縱向,才能觸發我的活動的事件。ScrollView卡住,直到onConfigurationChaged()被調用

我試過我的Nexus S(2.3.3)和模擬器(4.0.3)上的活動,它顯示相同的怪異行爲。

我也試着玩佈局時應用到活動,仍然沒有運氣。

我的活動的XML佈局可以找到here(這有點長,我不想用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 
     android:name=".ConfirmationActivity" 
     android:configChanges="keyboardHidden|orientation" 
     android:theme="@android:style/Theme.NoTitleBar" /> 

回答

1

我把它練到通過在線性佈局中包裝我的TextView(它應該填充父級),如下所示:

<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" > 

     <TextView 
      android:id="@+id/tvTerms" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1.0" 
      android:paddingBottom="6dip" 
      android:paddingLeft="6dip" 
      android:paddingRight="6dip" 
      android:textColor="#000000" /> 
    </LinearLayout> 

這裏是怎麼回事時,我不能讓它滾動:

<TextView 
    android:id="@+id/tvTerms" 
    android:layout_width="fill_parent" 
    android:layout_height="0dip" 
    android:layout_weight="1.0" 
    android:paddingBottom="6dip" 
    android:paddingLeft="6dip" 
    android:paddingRight="6dip" 
    android:textColor="#000000" /> 

,現在它的滾動像它應該!