How to handle the click event in Listview in android?

I can not see where do you declare context. For the purpose of the intent creation you can use MainActivity.this lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(MainActivity.this, SendMessage.class); String message = “abc”; intent.putExtra(EXTRA_MESSAGE, message); startActivity(intent); } }); To retrieve the object upon … Read more