2013-01-05 74 views
0

嗨我創建了一個滑動抽屜,並創建了一個可滾動的xml文件,我想在用戶輕擊滑動抽屜內的按鈕時充氣。但是,當點擊按鈕時,空白屏幕除外。任何人都可以告訴我我做錯了什麼? 這裏是我的代碼: XML:在抽屜中充氣xml

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#FFFFFF" > 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/text2" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="center" 
     android:text="@string/text2" /> 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginTop="10sp" 
     android:adjustViewBounds="true" 
     android:src="@drawable/image"/> 

    <TextView 
     android:id="@+id/text1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginLeft="5sp" 
     android:layout_marginTop="10sp" 
     android:text="@string/text1" /> 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_marginTop="10sp" 
     android:adjustViewBounds="true" 
     android:src="@drawable/image1"/> 

</LinearLayout> 

和java:

next3.setOnClickListener(new View.OnClickListener() { 
    @Override 
    public void onClick(View view) { 
     getLayoutInflater().inflate(R.layout.activity, null); 
     slider.animateClose(); 


    } 
}); 

請幫幫忙!

回答

0

getLayoutInflater().inflate(R.layout.activity, null); 

創建(膨脹)佈局文件的內容,但你有沒有把返回的視圖中的任何地方。

你想把ScrollView放在滑動抽屜裏面嗎?如果是,請更改爲:

getLayoutInflater().inflate(R.layout.activity, slider);