如何让刚生成ListView的时候 就默认选中第一项?

解决方案 »

  1.   

    listView.setSelection(int index)
    看看这个方法呢。
      

  2.   

    不知道你是用的哪个adapter
    setItemSelected(0,true);
    我这么用过
    用的是arrayadapter 同时 setChoiceMode(List.CHOICE_MDE_SINGLE)
      

  3.   


    用的是ListAdapter  。
    意思是一进入listview的页面,就会把默认的某个选项高亮。
      

  4.   


    ListAdapter 这个接口???
      

  5.   

    是实现了ArrayAdapter ,ListAdapter 的引用,好像没有setItemSelected这个方法啊?
      

  6.   

    LVM_SETSELECTIONMARK wParam = 0; 
      lParam = (LPARAM)(INT) iIndex;获取ListView的句柄,对其进行发送消息:SendMessage(hwndLV, LVM_SETSELECTIONMARK, 0, iIndex);
      

  7.   


    如果是继承自 ListActivity 可以getListView().setItemChecked(x,x)
      

  8.   

    在android 2.1中要这样写
    mylist.setAdapter(arrayAdapter);
    mylist.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mylist.setSelected(true);
    mylist.setSelection(0);
    mylist.setItemChecked(0, true);
    其它版本的暂时还没时间调试
      

  9.   

    如需要阅读该回复,请登录或注册CSDN! 
    看10楼
      

  10.   

    重写一个继承BaseAdapter的类,定义private int selectedPosition = 0;// 初始选中第一行
    在getView()方法里设置
    if(selectedPosition==position){
    convertView.setBackgroundResource(R.drawable.scenebgfocus);
    }