0
listView가 대화 상자에 삽입되었습니다. 목록의 항목을 클릭하면 작업에 응답하지 않고 리스너를 설정하지만 이유를 이해할 수 없습니다 onItemClickListener
이 호출되지 않습니다.listView 항목이 클릭에 응답하지 않습니다.
public void init() {
toMeetDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
toMeetDialog.setContentView(R.layout.person_to_meet);
listOfPersonToFollow = (ListView) toMeetDialog.findViewById(R.id.list_view_to_meet);
confirmButton = (Button) toMeetDialog.findViewById(R.id.button_to_meet);
confirmButton.setOnClickListener(this);
listOfPersonToFollow.setOnItemClickListener(this);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(mapsActivity, R.layout.list_item_to_meet, mapsActivity.getPersonToFollow());
listOfPersonToFollow.setAdapter(arrayAdapter);
toMeetDialog.show();
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(mapsActivity, "hello", Toast.LENGTH_SHORT);
}
list_item_to_meet.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="26dp" />
person_to_meet.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="400px"
android:layout_height="match_parent"
android:layout_gravity="center"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical" >
<CheckedTextView
android:id="@+id/persons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/person_to_meet"
android:textColor="@color/opaque_red" />
<ListView
android:id="@+id/list_view_to_meet"
android:layout_width="match_parent"
android:layout_height="138dp" >
</ListView>
<Button
android:id="@+id/button_to_meet"
android:layout_width="218dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/confirm_to_meet" />
</LinearLayout>
이 코드 뭐가 잘못? 사전에 감사합니다.
'.show()를 추가하십시오;은'Toast.makeText' 줄 끝에 '그 아무것도에게 – mittelmania
덕분에 많이 변경하는 경우를 참조 우물, disctraction이었다 disurbraction everywhere .... – OiRc
전체 활동을 보지 않고도 말하기가 어렵습니다. listOfPersonToFollow.setOnItemClickListener (this); – James