Hi,

Like Peli and Mark said, the preferred way to perform contextual
actions with Android is to use a long press associated with a context
menu. There are examples of this in various sample apps, including
code.google.com/p/apps-for-android or code.google.com/p/shelves.

Another way to do it, but I would not recommend it, is to use
ListView's single choice mode and have buttons on screen to act on the
selected element. The problem with this is that you always have one
item selected.

The menu, the one that comes up when one presses the menu key, is
meant for global actions only, actions that affect the entire
activity.

On Wed, Jan 28, 2009 at 8:51 AM, Peli <peli0...@googlemail.com> wrote:
>
> Android also supports loooooooong-click, which is what you need.
> (see the Notepad example).
>
> Peli
> www.openintents.org
>
> On Jan 28, 5:29 pm, Andriy Zakharchuk <andriy.zakharc...@gmail.com>
> wrote:
>> Hello all,
>>
>> I have a question about touch mode (probably it was already asked,
>> sorry if so, but I couldn't find a discussion like this). It's not
>> about technical issues, everything more or less is clear here, it's
>> more about philosophy. Hope Romain Guy will have chance to look into
>> this.
>>
>> The simple task I'm working on is a CRUD application. I have several
>> entities stored in a database. Lets say users and groups. I have to
>> provide basic set of operations to a user: create, retrieve, update
>> and delete entity (CRUD).
>>
>> Using usual approach I would create two forms for each entity list and
>> form. List displays all records from the database and has commands
>> (menu items, toolbar buttons or whatever else) to add, edit, delete
>> records. Add command displays form to let user fill-in fields and add
>> new record. Edit command displays form with attributes of currently
>> selected record. Delete command removes currently selected record from
>> the database. Pretty common, eh?
>>
>> Android applications offer another model. We have three screens. I
>> call them: list, view and form. In Contacts application:
>> - list - is a list of contacts;
>> - view - is a screen with information and dial number/send sms
>> command;
>> - form - is a form for editing information about the contact.
>>
>> How CRUD commands are distributed (I don't consider other commands
>> like dial, send SMS).
>>
>> - list has only Add command in menu (and all possible commands in
>> context menu).
>> - view has Edit and Delete commands in menu,
>> - form is similar to the approach above.
>>
>> There is one thing that confuses me here. In the Contacts application
>> this approach looks perfect. Usually we have contacts with a number of
>> phone numbers assigned, so view screen is quite functional.
>>
>> But lets imagine that we need to work with an entity that has only one
>> attribute, e.g. 'users group' has only 'name' attribute. In this case
>> view screen is always almost empty, only group name is displayed in
>> the screen header (contact with only name filled looks very similar,
>> although you still have favourite flag set/unset action). Since I
>> don't have other actions to be performed on gorup, the only function
>> of this screen is to have edit and delete commands in options menu.
>> This seems confusing to me.
>>
>> I tried to implement it in a traditional way (the approach I described
>> first). So I created a list screen, put 'Add', 'Edit', 'Delete'
>> commands into menu. I couldn't get Edit and Delete menu commands
>> working in touch mode, because I couldn't obtain selected item.
>>
>> In case when click on a list item moves user to the form, Edit/Delete
>> commands are not needed in the options menu (in touch mode), entering
>> edit mode is implemented via click, but deletion is not possible.
>>
>> The only solution I see here:
>> - list screen options menu has only Add command;
>> - click on a list item is equal to the Edit command;
>> - Delete command is available only from the form screen (you can Save,
>> Discard or Delete).
>>
>> Yeah, it is Palm OS approach :) Using this approach I make my
>> application inconsistent with other Android applications.
>>
>> With Android approach I get almost empty almost non-functional view
>> screen, which makes me think that I'm doing something wrong.
>>
>> Any ideas on this?
>>
>> Thank you in advance.
> >
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

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

Reply via email to