2016-05-17 54 views

回答

-1
yourlayout.xml 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<Button 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="click" 
    android:id="@+id/click"/> 
<ListView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:visibility="invisible" 
    android:layout_below="@+id/click" 
    android:paddingLeft="30dp" 
    android:paddingRight="30dp" 
    android:id="@+id/list"/> 
</RelativeLayout> 

on your activity 
ListView list = (ListView) findViewById(R.id.list); 
final Button click = (Button) findViewById(R.id.click) 
click.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      list.setVisibility(list.getVisibility() == View.INVISIBLE ? View.VISIBLE : View.INVISIBLE); 
}); 
+0

謝謝,但我認爲,這個解決方案,列表視圖不會出現在前臺。此外,如果可能的話,我想要Xamarin表單的解決方案(在PCL項目中)。 –