I have seen many questions and answer regarding this issue. I tried almost all of them but none of the answers didn't work for me.
I am using Samsung S9 phone running Android 8.0.0 (API 26).
If I try the following code, I setOnItemClickListener is called.
mListView = (ListView) findViewById(R.id.azure_photo_list);
mListView.setDividerHeight(1);
registerForContextMenu(mListView);
// ListView Item Click Listener
mListView.setOnItemClickListener((parent, view, position, id) -> {
Intent intent = new Intent(getBaseContext(), AzureImageActivity.class);
intent.putExtra("image", images[position]);
startActivity(intent);
});
String[] images = ImageManager.ListImages();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(AzurePhotoList.this,
android.R.layout.simple_list_item_1, android.R.id.text1, images);
mListView.setAdapter(adapter);
Note that the layout is from the Android system and text view from the Android system. If I provide my own layout as follows:-
String[] images = ImageManager.ListImages();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(AzurePhotoList.this,
R.layout.content_azure_photo_list,R.id.azure_list_item_name, images);
Then setOnItemClickListener is not called anymore. What is wrong?