2013-01-05 297 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);