what is this technique in java and android?
please give basics about this technique
objlistview.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v, int position,long id)
{
Cursor cr=(Cursor)parent.getItemAtPosition(position);
int _id=cr.getInt(cr.getColumnIndex("_id"));
callview(_id);
}
});
thank you…
It’s an anonymous class – very popular for ActionListeners where you create them just where you need them. In your example, each time you create an instance of the
OnItemClickListenervia thenewkeyword you can specify theonItemClickbehaviour (via the method) right where it’s needed and bind it appropriately. This is all done in a succinct syntax and scope.