xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin"
android:orientation="horizontal"
tools:context=".MainActivity">
android:id="@+id/mainlist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:listSelector="@drawable/selector3">
ListView mainlist=(ListView)findViewById(R.id.mainlist);
mainlist.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
String[] arr1={"第一栏","第二栏","第三栏","第四栏","第五栏"};
ArrayAdapter adapter1=new ArrayAdapter(this,R.layout.layout_app_setting_listitem,arr1);
mainlist.setAdapter(adapter1);
mainlist.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
System.out.println(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
System.out.println("没有做出选择");
}
});
代码如何可是点击时不会触发该事件时什么原因,Click是可以触发的但是ItemSelected就是不行不知道什么原因,求大神解答