我有以下代码,但似乎无法弄清楚为什么我会收到上述错误消息。我显然知道这意味着什么,但我检查了括号,它们对我来说似乎是正确的。我正在运行 ADT 21.1.0。到目前为止,我已经尝试重新启动 Eclipse;重新启动我的电脑;并重新构建项目。
package cct.mad.lab;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class WalkList extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// storing string resources into Array
String[] players = getResources().getStringArray(R.array.players);
// Binding resources Array to ListAdapter
this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, players));
}
protected void onListItemClick (ListView 1, View v, int position, long id) {
String item = (String) getListAdapter().getItem(position);
Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
}
}