我正在尝试播放我设置的OnItemClick
声音。ListView
我收到错误“create(Context, int)
类型MediaPlayer
中的方法不适用于参数(new AdapterView.OnItemClickListener(){}, int)
”,“create”下划线。
不是 100% 确定我为什么会收到此错误,如果有人可以提供帮助,将不胜感激。
ListView BoardList = (ListView) findViewById(R.id.BoardList);
BoardList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
String List[] = {"Play 1", "Play 2", "Play 3", "Play 4", "Play 5", "Play 6", "Play 7", "Play 8", "Play 9" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.listcustomize, R.id.textItem, List);
BoardList.setAdapter(adapter);
BoardList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == 0) {
MediaPlayer mPlayer = MediaPlayer.create(this, R.raw.Audio1);
mPlayer .start();
}
}
});