add buttons to ListActivity
How do you include add, remove, and ba开发者_运维百科ck buttons in ListActivity .pl?
You can have your header/footer in a LinearLayout or RelativeLayout along with your ListView defined in XML, and pass it to setContentView; alternatively you can add a header or footer view programatically to your list view with addHeaderView or addFooterView. If that header/footer layout is a LinearLayout or RelativeLayout, you can jam your three buttons in that layout.
However, think if this is actually what you want to be doing from a UI standpoint. On Android (unlike the iPhone), the hardware "back" button usually functions as "back," so you don't really need an onscreen back button, for starters. And a "delete" button interaction would be fairly unpleasant (How do you select an item to be deleted? press delete, then select an item? That's not going to be expected by Android users)... take your cues from the system apps like the Browser, just have a long-press context menu to delete items if needed (The exception: If deleting is a very common operation, use checkboxes for bulk operations a la the system GMail app).
Put them in a layout XML file along with your ListView
, and give that layout to the ListActivity in onCreate()
via setContentView()
.
精彩评论