Table of Contents

Android - Event Handling

About

Views object handle events.

Example

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String message = (String) parent.getItemAtPosition(position);
                Context context = getContext();
                CharSequence text = message;
                int duration = Toast.LENGTH_SHORT;
                Toast toast = Toast.makeText(context, text, duration);
                toast.show();
            }
        });

with: