1

The New York Times app seems to have a SlideDrawer that pulls down over a ListAdapter. This is the effect I am trying to accomplish. I have a custom listadapter that works fine on its own, and I have a slidedrawer that works fine, on its own. They are two separate Activities. I want to merge the two so that there is a slidedraw over the listadapter.

I have tried SetContentView on the ListActivity that implements my ArrayAdapter to the xml file that houses the slide drawer, but i get a forceclose. I think its because a listadapter is essentially a bunch of tiny inflated views of the same xml layout, and I'm trying to run two layouts at the same time. I've thought maybe the answer lies in how the xml file is laid out but honestly have no idea.

anyways here's the code:

import android.view.View;
import android.net.Uri;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.SlidingDrawer;
import android.widget.AdapterView.OnItemClickListener;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;

public class BandApp extends ListActivity {
/** Called when the activity is first created. */


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

//here is where I have tried setting slidedrawer layout 
    setContentView(R.layout.slidedrawer)

    Activity activity = this;
    activity.setTitle("@$@#$$@$#$");


    final String[] values = {"Litem0","Litem1","Litem2","Litem3","Litem4","Litem5"};

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

and for the 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="85dp"
>
<TextView
android:layout_height="0dp"
android:layout_width="0dp"
android:id="@+id/textlayout"
/>
</LinearLayout>

Like I said, they both work fine on there own but I'm wondering how to merge the two and gain the effect found on the New York Times app. Thank you.

Here is an image of what i'm talking about. The "dine and wine" at the top pulls down, so I'm guessing its a slidedrawer?:

enter image description here

Parth Doshi
  • 4,200
  • 15
  • 79
  • 129
Bob
  • 1,088
  • 1
  • 9
  • 15
  • Not everyone who might help you has the New York Times app. Please consider adding screenshots to your questions to illustrate what you mean. – CommonsWare Dec 24 '11 at 01:43

1 Answers1

0

A Sliding drawer may only come from the bottom, or the right. It cannot come from the top. You could check out this question for some possible solutions.

However the code you have won't even get you a normal sliding drawer. What you need is both a ListView and a SlidingDrawer (with handle, etc) in your XML, and all of that should be in a layout that allows things to overlap, like RelativeLayout. Then in your activity, you will set that as the content view.

There is a recipe here, that will get a ListView to be above a SlidingDrawer, which can sometimes be tricky

Community
  • 1
  • 1
JeffS
  • 2,647
  • 2
  • 19
  • 24
  • Thanks, yeah I know I didn't put the XML for the sliding drawer because I thought it was superfluous as the code is pretty simple. You should know that I can get a slidingdrawer to occur, no problem there, just not along with the listadapter too - setContentView(R.id.slidedrawer), which is the xml file, works by itself; when I use it with setListAdapter(Adapter) it doesn't. – Bob Dec 24 '11 at 05:09
  • and the slidedrawer.xml file has both the listview and the SlidingDrawer in it? – JeffS Dec 24 '11 at 22:03
  • OK see where my layout went wrong - here's a good example of what I was looking for: [link](http://w2davids.wordpress.com/android-damn-that-sliding-drawer/). So I need to make a FrameLayout, with a LinearLayout and a SlidingDrawer, then have set the Adapter to the LinearLayout. – Bob Dec 24 '11 at 22:58
  • You'd set the content view to be the FrameLayout, and then call ListActivity.setListAdapter() – JeffS Dec 25 '11 at 03:25