after some more playing around i've found my code works, but only if
use the keyboard.  no touch or mouse in emulator.

anybody had a clue to where i've gone wrong?    here's some updated
code --

        private void fillData() {
                ArrayList<String> names = new ArrayList<String>();
                for (int i = 0; i < _options.length; i++) {
                        String item = (String) _options[i];
                        if (_selections[i]) names.add(item);
                }
                _taskCursor = _dbHelper.fetchTasksByName(names);
                startManagingCursor(_taskCursor);

                String[] from = new String[] { TaskDbAdapter.KEY_ITEM,
TaskDbAdapter.KEY_CATEGORY, TaskDbAdapter.KEY_DATE };
                int[] to = new int[] { R.id.category_entry, R.id.item_entry,
R.id.date_completed };

                ListAdapter listAdapter = new ListAdapter(this, 
R.layout.list_item,
_taskCursor, from, to);
 
getListView().setOnCreateContextMenuListener(this);
                setListAdapter(listAdapter);
        }


    final class ListAdapter extends SimpleCursorAdapter implements
View.OnClickListener {

                @Override
                public View newView(Context context, Cursor cursor, ViewGroup
parent) {
                LayoutInflater inflater =
(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View view = inflater.inflate(R.layout.list_item, parent,
false);
                return view;
                }


                @Override
                public void bindView(View view, Context context, Cursor c) {
                        TextView itemView = (TextView) 
view.findViewById(R.id.item_entry);
                        TextView categoryView = (TextView)
view.findViewById(R.id.category_entry);
                        TextView dateView = (TextView)
view.findViewById(R.id.date_completed);

        
itemView.setText(c.getString(c.getColumnIndexOrThrow(TaskDbAdapter.KEY_ITEM)));
                        itemView.setFocusable(false);
                        itemView.setFocusableInTouchMode(false);
        
categoryView.setText(c.getString(c.getColumnIndexOrThrow(TaskDbAdapter.KEY_CATEGORY)));
                        dateView.setText(_listFormat.format(new
Date(c.getLong(c.getColumnIndexOrThrow(TaskDbAdapter.KEY_DATE)))));

                        view.setOnClickListener(this);
                        // view.setOnCreateContextMenuListener(ViewTasks.this); 
 // this
works - kinda of.. with no menuInfo
                        view.setTag(c.getPosition());

                }

.........


}



On May 5, 4:11 pm, denov <d...@syncopated.net> wrote:
> when i add thestyleattribute for the my relativeLayout below 
> itbreakstheonClickeventsin my activity.
>
> ---
>
> <stylename="list_item_bl" parent="text_large_bl">
>         <item name="android:paddingRight">4sp</item>
>         <item name="android:paddingLeft">4sp</item>
>         <item name="android:background">@drawable/list_item_bl</item>
>         <item name="android:focusable">false</item>
>         <item name="android:focusableInTouchMode">false</item>
>         <item name="android:clickable">true</item>
> </style>
>
> <?xmlversion="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>                 android:orientation="vertical"
>                 android:layout_width="fill_parent"
>                 android:layout_height="fill_parent">
>
>         <TextView android:id="@+id/TextView01"
>                           android:layout_height="wrap_content"
>                           android:text="blah blah blah... blah blah"
>                           android:textStyle="normal|bold"
>                           android:gravity="center_vertical|center_horizontal"
>                           android:layout_width="fill_parent" />
>
>         <ListView android:id="@android:id/list"
>                           android:layout_height="wrap_content"
>                           android:layout_width="fill_parent" />
>         <TextView
>                 android:id="@+id/android:empty"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:text="@string/nothing" />
>
>  </LinearLayout>
>
> <?xmlversion="1.0" encoding="utf-8"?>
> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>                 android:layout_width="fill_parent"
>         android:layout_height="wrap_content"
>         android:orientation="horizontal"
>         android:id="@+id/list_item"
>        style="?listItem" >
>
>         <TextView
>                 android:id="@+id/item_entry"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:gravity="left" android:focusable="false"
> android:focusableInTouchMode="false"/>
>     <TextView
>                 android:id="@+id/category_entry"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:layout_toRightOf="@id/item_entry"
>                 android:gravity="right"
>                 android:paddingLeft="8sp" android:focusable="false"
> android:focusableInTouchMode="false"/>
>     <TextView
>                 android:id="@+id/date_completed"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:layout_alignParentRight="true"
>                 android:gravity="right"
>                 android:paddingLeft="4sp" android:focusable="false"
> android:focusableInTouchMode="false"/>
>
> </RelativeLayout>
>
> ----
>
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>
>          ....
>
>         fillData();
>         getListView().setOnCreateContextMenuListener(this);
>
>     }
>
>         private void fillData() {
>                 ArrayList<String> names = new ArrayList<String>();
>                 for (int i = 0; i < _options.length; i++) {
>                         String item = (String) _options[i];
>                         if (_selections[i]) names.add(item);
>                 }
>                 _taskCursor = _dbHelper.fetchTasksByName(names);
>                 startManagingCursor(_taskCursor);
>
>                 String[] from = new String[] { TaskDbAdapter.KEY_ITEM,
> TaskDbAdapter.KEY_CATEGORY, TaskDbAdapter.KEY_DATE };
>                 int[] to = new int[] { R.id.category_entry, R.id.item_entry,
> R.id.date_completed };
>
>                 ListAdapter notesAdapter = new ListAdapter(this, 
> R.layout.list_item,
> _taskCursor, from, to);
>                 //SimpleCursorAdapter notesAdapter = new 
> SimpleCursorAdapter(this,
> R.layout.list_item, taskCursor, from, to)
>                 notesAdapter.setViewBinder(new ViewBinder() {
>                                 public boolean setViewValue(View aView, 
> Cursor aCursor, int
> aColumnIndex) {
>                                         if (aColumnIndex == 3) {
>                                                 Date createDate = new 
> Date(aCursor.getLong(aColumnIndex));
>                                                 TextView textView = 
> (TextView) aView;
>                                                 
> textView.setText(listFormat.format(createDate));
>                                                 return true;
>                                         }
>                                         return false;
>                                 }
>                 });
>
>                 setListAdapter(notesAdapter);
>         }
>
> ---
>
> i wrote a custom ListAdapter to see that would solve my problem.  i
> can catch the listOnClick this way (with a lot of extra work) but
> onCreateContextMenu never seems to get invoked.
>
> this seems really weird that applying astylewould break event
> handling...

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