listview: onItemClickListener is not called


Last Updated:

  1. krish.chauhan

    krish.chauhan New Member This Topic's Starter

    Joined:
    Dec 27, 2009
    Messages:
    3
    Likes Received:
    0
    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());
    }
     

    Advertisement

Share This Page

Loading...