tags:

views:

45

answers:

3

I have an activity that calls the

new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
setListAdapter(notes);

I would like to add a button to the notes_row.xml that displays at the bottom of the screen "on top of" the actual notes_row allowing the user to still scroll through the list but hit the button if they want. Every time I try to change the layout of notes_row, I get the button on each item in the list. I am pretty new to Android and I think I need to inflate the button somehow so that it is layered in front of the list but doesn't impede the list, how do I go about doing that?

A: 

The R.layout.notes_row is the layout for each individual row. You will need to create a custom ListView.

Here is a tutorial: http://www.androidpeople.com/android-custom-listview-tutorial-example/

Adam Driscoll
Thank you, I will check that out.
Will
A: 

It sounds like you are adding the button to the notes_row layout. That will add it to each row.

Instead, you want to add it to the layout for the Activity. Are you extending from ListActivity? You could try adding the button as a footer to the ListView.

Otherwise, you can extend from a standard Activity and supply a layout file for that activity that includes a ListView and a Button. If you haven't yet, read through declaring layout and common layout objects to get a start on creating a layout.

Mayra
Cool, thank you very much, back to the experimentation.
Will
A: 

If you will try to edit notes_row.xml file and add a button there it will come in each row, what you can do .. try editing the xml for the parent activity where you are trying to put you list view. In that xml you can easily put a button at the bottom

success_anil
How do I know which view is the parent activity - sorry, I know it sounds like a stupid question, but I am terribly new at this.
Will
I tried to enter a button into the notes_list.xml file, which I assumed was the parent view being that notes_row only holds the text ids. But the button still didn't display, is there some special trick to adding the button that I am missing, I just added it as a button with an @+id/ and then instantiated the button in notepadV3.java. The activity still displays but that is all, no button or anything.
Will
Try declaring your Button and ListView inside of a RelativeLayout, and anchoring the button to the bottom of the parent, and the ListView to the top of the parent or above the button (you have some options here). I did it this way in my app, although I'm going to take a look at the footer implementation that Mayra mentioned. Thanks Mayra!
McStretch
Please post your code .
success_anil