Android: CustomListAdapter

Posted by primal on Stack Overflow See other posts from Stack Overflow or by primal
Published on 2010-05-17T08:09:41Z Indexed on 2010/05/17 8:20 UTC
Read the original article Hit count: 263

Filed under:
|
|

Hi,

I have implemented a custom list view which looks like the twitter timeline.

adapter = new MyClickableListAdapter(this, R.layout.timeline, mObjectList);
       setListAdapter(adapter);

The constructor for MyClickableListAdapter is as follows

private class MyClickableListAdapter extends ClickableListAdapter{

  public MyClickableListAdapter(Context context, int viewId, List objects) {
   super(context, viewId, objects);
  }

ClickableListAdapter extends BaseAdapter and implements the necessary methods.

The xml code for the list view is as follows

<ListView
    android:id="@+id/android:list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />  

This is what it looks like.

I have 3 questions

1) I tried registering a context menu for the list view by adding the line after setting the list adapter

registerforContextMenu(getListView());

But on long-click the menu doesnt get displayed. I cannot understand what I am doing wrong!

2) Is it possible to display a textview above the listview? I tried it by adding the code for textview above the listview. But then, only the textview gets displayed.

3) I have seen in many twitter clients that on clicking post a window pops up from the top covering only some portion of the screen and rest of the timeline is visible. How can this be done possibly without starting a new activity?

Any help would be much appreciated..

© Stack Overflow or respective owner

Related posts about android

Related posts about contextmenu