我再做一个答题测试的小软件,用的ListView来做答案选项,如何给ListView加载监听实现答题是否正确,并在所有答题结束后的总结页面统计出最后得分,要用run方法能实现吗? 

解决方案 »

  1.   

    listview可以设置监听OnItemClickListener,监听每次返回你点击的寻个item项的一系列参数。很简单,很好用,看看API或网上搜一下样码都可以
      

  2.   

    OnItemClickListener会有一个返回ID序列给你,跟你数据源的序列一样,在这个回调函数里提取ID再根据逻辑做相应的操作即可
      

  3.   

    protected void onListItemClick(ListView l, View v, int position, long id) {
    // TODO Auto-generated method stub
    /*Mp3Info mp3Info=mp3Infos.get(position);
    System.out.println("mp3Info---->" + mp3Info);
    Intent intent =new Intent(); 
    intent.putExtra("mp3Info",mp3Info);
    intent.setClass(this,DownloadService.class);
    startService(intent);*/
    super.onListItemClick(l, v, position, id);
    }