일부 이미지가있는 GridView와 새 이미지를 추가하는 버튼을 표시하기 위해 프래그먼트를 사용하고 있습니다. GridView 잘 작동하지만 내 단추의 onClick 메서드는 절대로 호출됩니다.버튼 onClick 메서드가 내부에서 호출되지 않았습니다.
이 내 조각의 onCreateView 방법입니다 :
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_picture_grid_view, container, false);
addPictureButton = (Button) rootView.findViewById(R.id.fragment_grid_view_add_button);
addPictureButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CameraOrAlbumDialogFragment dialogFragment = new CameraOrAlbumDialogFragment();
dialogFragment.show(mContext.getSupportFragmentManager(), "CameraPicker");
}
});
imageGridView = (GridView) rootView.findViewById(R.id.fragment_grid_view);
imageGridView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
} 내 onActivityCreated 방법에서
내의 GridView에 대한 모든 어댑터 물건을하고, 정상적으로 작동하는 내 클릭 및 longClicks을 캡처 할 수 있습니다. 작동하지 않는 유일한 방법은 Button의 onCLick 메소드입니다. 버튼 아이콘을 만졌을 때 버튼 아이콘이 바뀌는 것을 볼 수 있지만, 내 onClickListener 메소드 내부의 함수는 절대로 호출되지 않습니다. 어떤 도움이 필요합니까?
편집
이 내 조각 레이아웃입니다 : 그 버튼의 onclick 이벤트를 받기 그래서
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<GridView
android:id="@+id/fragment_grid_view"
android:layout_width="match_parent"
android:layout_height="150dp"
android:numColumns="auto_fit" >
</GridView>
<Button
android:id="@+id/fragment_grid_view_add_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Add Picture" />
</LinearLayout>
EDIT2
, 내 버튼을 오버랩하는 또 다른 버튼을가 있다고 밝혀 내 버튼 대신에. 내가 이클립스에서 Hierarchy 뷰를 사용할 때 알아낼 수 있었다. 매우 유용합니다.
onClick이 호출되지 않았거나 표시되지 않는 dialogFragment입니까? – fasteque
mContext.getSupportFragmentManager() 대신 getFragmentManager를 사용해야합니다. – Blackbelt
지금까지 호출되지 않았습니다. 나는 onClick 내부에 토스트를 넣으려고했지만 결코 나타나지 않습니다. – digovs