2012-06-04 79 views
0

我已經創建了一個列表/表,按以下代碼排序。如何設置SimpleAdapter的偵聽器

ListView list = (ListView) findViewById(R.id.list1); 
    btn = (Button) findViewById(R.id.btTaken); 
    ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>(); 
    HashMap<String, String> map = new HashMap<String, String>(); 
    String Date; 
    //list.setOnItemSelectedListener((OnItemSelectedListener) this); 
// list.setOnItemClickListener(ListItemClick); 
    // cb.setVisibility(); 
    Date=AttendanceDao.Dates()[0]; 
    for(i=0;i<AttendanceDao.Dates().length;i++) 
    { 

    map = new HashMap<String, String>(); 
    map.put("Date", AttendanceDao.Dates()[i]); 
    //map.put("StudentName",Data.Sname()[i]); 

    mylist.add(map); 
    } 

    // ... 
    SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, R.layout.att_date_list, 
      AttendanceDao.Datemap(), new int[] {R.id.Sid}); 

    list.setAdapter(mSchedule); 

代碼

protected void onListItemClick(ListView l, View v, int position, long id) {//this guy is not working! 
      // TODO Auto-generated method stub 
      Intent openActivity = new Intent("net.vrixx.activities.ATTENDANCELISTACTIVITY"); 
       startActivity(openActivity); 

     } 

的這部分應該聽單擊的項目我的名單上。但它不起作用任何人都可以找出原因嗎?謝謝!

+0

是ListActivity還是? –

+0

檢查我的回答 – Akram

+0

它從一個活動只延伸到.. 我有兩個xml佈局這..一般佈局,其中提及列表和其他xml我描述必須在列表中的意見。 –

回答

0
list.setOnItemSelectedListener(new OnItemSelectedListener() { 

     @Override 
     public void onItemSelected(AdapterView<?> arg0, View arg1, 
       int arg2, long arg3) { 
      // TODO Auto-generated method stub 

     } 

     @Override 
     public void onNothingSelected(AdapterView<?> arg0) { 
      // TODO Auto-generated method stub 

     } 
    });