2011-06-04 111 views
0

第一個基本上我需要在應用程序啓動時進行佈局。
第二個我從這個佈局的視圖中獲取數據。
進出口設置下一個佈局,並做艱苦的工作代碼與數據,我在第2步兩種佈局在一個活動中,尋找解決方案

了我無法弄清楚如何做到這一點。

+0

哪一步你不明白?三個全部?你已經嘗試了什麼? – inazaruk 2011-06-04 09:33:48

回答

0

您可以在沒有任何動畫的情況下重新使用框架類ViewAnimator。這不是最漂亮的解決方案,但應該完成工作。

的main.xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical"> 

    <ViewAnimator xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_height="fill_parent" 
        android:layout_width="fill_parent" 
       android:id="@+id/viewFlipper" /> 

</LinearLayout> 

MyActivity.java:

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.main); 

    viewAnimator = (ViewAnimator)findViewById(R.id.viewFlipper); 
    viewOne = createViewOne(); 
    viewTwo = createViewTwo(); 

    viewAnimator.addView(viewOne); 
    viewAnimator.addView(viewTwo); 
    ... 
} 

private void someMethod() { 
    ... do my background task ... 
    viewAnimator.setDisplayedChild(1); // viewTwo 
}