这是代码:
public class BookingActivity extends Activity {
static final String[] StrValues = new String[] { "Resturant", "Hotell" };
ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activitybooking);
listView = (ListView) findViewById(R.id.listView1);
listView.setAdapter(new ImageAdapter(this, StrValues));
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Intent myIntent = new Intent(ListActivity.this, eksempelActivity.class);
myIntent.putExtra("Resturant", StrValues);
ListActivity.this.startActivity(myIntent);
}
});
}
}
并且我收到此错误: 在范围内无法访问 ListActivity 类型的封闭实例
我已经导入了必要的导入,包括 listactivy 和 AdapterView.OnItemClickListener。我什至尝试将 setonitemclicklistener-method 更改为 onitemclicklistener,但结果为 0。