0

我试图让 Listview 变得可点击,但如果有任何方法/函数被调用,它会立即崩溃,比如 toast();

    listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, arrayListCarros);  
    mainListView.setAdapter( listAdapter );      
    db.close();



    mainListView.setClickable(true);
    mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            toast(position);

      }
    }); 
4

1 回答 1

0
 mainListView.setClickable(true);
    mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            Toast.makeText(activityname.this, String.valueOf(position), Toast.LENGTH_SHORT).show();

            Intent intent = new intent(activityName.this,targerActivity.class);
            activityName.this.startActivity(intent);    
  }
于 2012-11-19T21:19:24.430 回答