Hello Guys,
I've written the following but I cannot figure out how to add the non
scrolling header Item. If I only extent an Activity then I cannot
override the onListItemClick method. This is why I have written it to
use the ListActivity class. Any help would be greatly appreciated,
here is my code so far:

public class HelloListAdapter extends ListActivity {

        private ListView lv;
        private TextView tv;
        private ListAdapter la;

        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        tv = new TextView(this);
        tv.setText("Hello Text, Top of List");

        lv = (ListView) getListView();
        lv.addHeaderView(tv);

        la = (ListAdapter) new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, COUNTRIES);
        lv.setAdapter(la);

    }

    static final String[] COUNTRIES = new String[] {
        "Afghanistan", "Albania", "Algeria", "American Samoa",
"Andorra",
        "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda",
"Argentina"
    };
}

On Jul 31, 1:49 pm, Atif <[email protected]> wrote:
> I have similar issue with TableLayout. There must be some mechanism to
> define non scrolling header row. If I took out my header row from
> ScrollView+TableLayout and define it in new layout than the columns
> are not aligned.
>
> Regards,
> Atif
>
> On Jun 26, 3:35 am, Mike <[email protected]> wrote:
>
> > I use the same view for my rows as I do my table header, so in order
> > for them to size correctly (make sure the columns in the header line
> > up with the column in the rows), they have to be within the same
> > container to have the same width, correct?  That's all I meant by
> > needing to be in the same ViewGroup.
>
> > - Mike
>
> > On Jun 25, 9:54 am, Marco Nelissen <[email protected]> wrote:
>
> > > On Thu, Jun 25, 2009 at 8:46 AM, Mike 
> > > <[email protected]>wrote:
>
> > > > Thanks guys.  This does work provided the ListView and the header View
> > > > are within the same parent ViewGroup.
>
> > > Can you give an example of when they would not be?
>
> > > > I would, however, like to request that the ListView be enhanced with
> > > > two new methods:
>
> > > > voidaddHeaderView(View v, Object data, boolean isSelectable, boolean
> > > > scrollsWithContent)
> > > > void addFooterView(View v, Object data, boolean isSelectable, boolean
> > > > scrollsWithContent)
>
> > > > This would allow a dev to leave management of the headers and footers
> > > > entirely with the ListView and provide the ability to have "sticky"
> > > > headers and footers that are owned by the ListView.
>
> > > What's the advantage of this over putting your headerview above the 
> > > ListView
> > > in a LinearLayout?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to