可以在ListView布局上使用SlidingDraw布局吗?

时间:2011-12-22 23:48:43

标签: android android-listview slidingdrawer custom-lists

我想知道是否有可能 - 以及如何 - 将SlidingDraw放在listView上?情况是:我有一个自定义列表适配器 - 膨胀布局和所有这些 - 创建一个列表。我想对此列表进行滑动绘制。但是当我尝试使用SlidingDrawer代码将主布局设置为xml文件时,我会强行关闭,因为我认为它干扰了适配器。谢谢你的任何建议。

这是我的大部分代码:

public class BandApp extends ListActivity {

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

        //this is where I have a problem
        setContentView(R.layout.main); 

        Activity activity = this;
        activity.setTitle("Title");

        final String[] values = {"(where i put some urls)","@","@","@","@"};

        MyAdapter Adapter = new MyAdapter(this, values);
        setListAdapter(Adapter);

当我删除setContentView它工作时,当我添加它时,它不会(强制关闭)。但这是使用SlideDrawer的xml布局。 :/感谢您的帮助

这是xml代码:

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

     android:handle="@+id/handle"
     android:content="@+id/content">

     <ImageView
         android:id="@id/handle"
         android:layout_width="88dip"
         android:layout_height="44dip" />

     <GridView
         android:id="@id/content"
         android:layout_width="match_parent"
         android:layout_height="match_parent" />

     </SlidingDrawer>
     </LinearLayout>

1 个答案:

答案 0 :(得分:0)

你绝对可以做到,它完全适用于我的应用程序。事实上在SlidingDrawer中,我有一个GridView。这里是一些xml文件:

...
<ListView android:id="@id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@null"
    android:layout_weight="1"
    android:drawSelectorOnTop="false"
    android:focusable="false"
    android:divider="@null"
    android:alwaysDrawnWithCache="true"
    android:layout_marginBottom="30dip"
    />

<SlidingDrawer
     android:id="@+id/drawer"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:handle="@+id/handle"
     android:content="@+id/browse_all_grid_view">

     <Button android:id="@id/handle"
        android:layout_width="fill_parent" 
        android:layout_height="30dip"
        android:layout_marginLeft="10dip"
        android:layout_marginRight="10dip"
        android:layout_centerVertical="true"
        android:layout_alignParentRight="true"
        android:textColor="#ffffffff"
        android:text="Pull out text"/>

     <GridView
         android:id="@+id/browse_all_grid_view"
         android:background="@drawable/background_dark"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent" 
         android:verticalSpacing="2dp"
         android:horizontalSpacing="0dp"
         android:numColumns="2"
         />

</SlidingDrawer>
...
相关问题