• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps listview: onItemClickListener is not called

Hi ,

My OnItemClickListener is not called when i set it on list view. What can be the possible reason.

Following is the code for same.
public void updateList(){
view =(ListView)findViewById(R.id.listv);
// view.setDescendantFocusability(ListView.FOCUS_AFTER_DESCENDANTS);
// view.setOnKeyListener(this);
// view.setDrawingCacheEnabled(false);
// view.setSelectionAfterHeaderView();
// view.setScrollingCacheEnabled(false);
// view.setBackgroundColor(Color.WHITE);
Vector<RSSItem> messages = PersistanceHandler.getItems();

if (messages.size() > 0) {
messages.elementAt(selectedIndex).setFocused(true);
}

ArrayList<RSSItem> msglist = new ArrayList<RSSItem>();
// int size = messages.size();
int start=currentPageIndex*ITEM_PER_PAGE;
int end=((start+ITEM_PER_PAGE+1) <messages.size())?(start+ITEM_PER_PAGE+1):messages.size();

for (int i = start; i < end; i++) {
msglist.add(messages.elementAt(i));
}
view.setClickable(true);
try{
view.setOnItemClickListener(new AdapterView.OnItemClickListener(){
public void onItemClick(AdapterView<?> parent, View view, int position, long rowID) {
if(view instanceof InboxAdapterView){
Log.d("Click"," krishan");
}

}
});

}catch(Exception ex){
System.out.println("nothing");
}
inbox = new InboxAdapter(Home.this, msglist);
view.setAdapter(inbox);
Log.d(" rent a coder ",""+ view.getOnItemClickListener());
}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones