Finally I found the problem. I'm not sure whether it's a bug of
ArrayAdapter.....
Following is part of my code:

public class myActivity extends ListActivity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.lobbygamelist);
                registerForContextMenu(getListView());
                setListAdapter(new GameListAdapter ());
        }

class GameListAdapter extends ArrayAdapter<String>{
.......
public View getView(int position, View convertView, ViewGroup parent)
{
                        View row = convertView;
                        if (row == null) {
                                LayoutInflater inflater = getLayoutInflater();
                                row = inflater.inflate(R.layout.gamerow, 
parent, false);
                        }
                        ViewHolder holder=(ViewHolder)row.getTag();
                        if (holder==null) {
                                holder=new ViewHolder(row);
                                row.setTag(holder);
                        }
                        holder.watchNumber.setText("");
                        holder.playerWhite.setText("");

                        //////this call will disable context menu in
touch mode
                        this.notifyDataSetChanged();
}
}


1. When "notifyDataSetChanged" was called in "getView" of
"ArrayAdapter", context menu can not created in touch mode.
2. remove "notifyDataSetChanged" call, everything fine....





On 3月15日, 上午7时46分, Mark Murphy <[email protected]> wrote:
> On Mon, Mar 14, 2011 at 7:43 PM, Tony <[email protected]> wrote:
> > I searched almost all threads related touch mode. And I know select
> > and focus is disable in touch mode. It seems I can use context menu.
> > But the problem is context menu work just fine in select mode. In
> > touch mode, context menu did not show when long press on listview
> > item.
>
> Context menus work just fine in touch mode:
>
> https://github.com/commonsguy/cw-android/tree/master/Menus/Inflationhttps://github.com/commonsguy/cw-android/tree/master/Menus/Menus
>
> > So my question is even for context menu(not onListItemClick ), I have
> > to enable ListView choice mode?
>
> No.
>
> > And thus I have to enable filtering
> > for litview?
>
> No.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android Training in Oslo:http://bit.ly/fjBo24

-- 
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