0
나는이 TabLayout 5 조각, 한 조각 사용지도보기 및 "ListFragment"를 사용하여 다른 조각을 사용하지만 문제가 하나 명의 활동 :Android. 그나마 작업 ListFragment onListItemClick()
ListFragment onListItemClick을 (활성화되지 않음)
많이 했어.하지만 해결하기가 어렵습니다.
이 코드
내 코드 :<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:descendantFocusability="blocksDescendants"
tools:context = "com.prebation.myapplication.h1_page">
<android.support.design.widget.TabLayout
android:id="@+id/tab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="@color/cast_libraries_material_featurehighlight_outer_highlight_default_color"
app:tabSelectedTextColor="@color/cast_intro_overlay_button_background_color" />
<com.prebation.myapplication.NonSwipeViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:layout_height="match_parent"
android:layout_below="@id/tab" />
^활동 XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginBottom="5dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:layout_marginRight="5dp"
android:background="@drawable/round_angle"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
app:srcCompat="@drawable/hosp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/list_hos_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="병원이름"
android:textSize="18sp" />
<TextView
android:id="@+id/list_hos_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:text="병원거리" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:orientation="horizontal">
<RatingBar
android:id="@+id/list_hos_star"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:isIndicator="true"
android:rating="2.5" />
<TextView
android:id="@+id/list_hos_review"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_weight="1"
android:text="리뷰" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginBottom="5dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@color/cast_expanded_controller_ad_label_background_color"
android:text="대기인원"
android:textColor="@android:color/white" />
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_weight="1"
android:background="@color/cast_expanded_controller_ad_label_background_color"
android:text="접수/예약"
android:textColor="@android:color/white" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_weight="1"
android:background="@color/cast_expanded_controller_ad_label_background_color"
android:text="결제가능"
android:textColor="@android:color/white" />
</LinearLayout>
</LinearLayout>
<ImageButton
android:id="@+id/list_call_bt"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:focusable="false"
android:background="@android:color/white"
app:srcCompat="@android:drawable/sym_action_call" />
^list_layout_xml 한 이미지 뷰, 하나 RatingBar, 하나하여 ImageButton을 사용하여, 여섯 텍스트 뷰
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
adapter = new Listview_Fragment_item_Adapter() ;
adapter.addItem("연세 내과","서울특별시 강남구 수서동 715","리뷰(50)","010-8424-6121","평일 09:30 ~ 18:30","주말 09:30 ~ 12:30");
adapter.addItem("연세 내과","서울특별시 강남구 수서동 715","리뷰(50)","010-8424-6122","평일 09:30 ~ 18:30","주말 09:30 ~ 12:30");
adapter.addItem("연세 내과","서울특별시 강남구 수서동 715","리뷰(50)","010-8424-6123","평일 09:30 ~ 18:30","주말 09:30 ~ 12:30");
adapter.addItem("연세 내과","서울특별시 강남구 수서동 715","리뷰(50)","010-8424-6124","평일 09:30 ~ 18:30","주말 09:30 ~ 12:30");
adapter.addItem("연세 내과","서울특별시 강남구 수서동 715","리뷰(50)","010-8424-6125","평일 09:30 ~ 18:30","주말 09:30 ~ 12:30");
adapter.addItem("연세 내과","서울특별시 강남구 수서동 715","리뷰(50)","010-8424-6126","평일 09:30 ~ 18:30","주말 09:30 ~ 12:30");
adapter.addItem("연세 내과","서울특별시 강남구 수서동 715","리뷰(50)","010-8424-6127","평일 09:30 ~ 18:30","주말 09:30 ~ 12:30");
adapter.addItem("연세 내과","서울특별시 강남구 수서동 715","리뷰(50)","010-8424-6129","평일 09:30 ~ 18:30","주말 09:30 ~ 12:30");
adapter.addItem("연세 내과","서울특별시 강남구 수서동 715","리뷰(50)","010-8424-6129","평일 09:30 ~ 18:30","주말 09:30 ~ 12:30");
adapter.addItem("연세 내과","서울특별시 강남구 수서동 715","리뷰(50)","010-8424-6129","평일 09:30 ~ 18:30","주말 09:30 ~ 12:30");
adapter.addItem("연세 내과","서울특별시 강남구 수서동 715","리뷰(50)","010-8424-6129","평일 09:30 ~ 18:30","주말 09:30 ~ 12:30");
adapter.addItem("연세 내과","서울특별시 강남구 수서동 715","리뷰(50)","010-8424-6129","평일 09:30 ~ 18:30","주말 09:30 ~ 12:30");
setListAdapter(adapter) ;
return super.onCreateView(inflater, container, savedInstanceState);
}
@Override
public void onListItemClick (ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// get TextView's Text.
Listview_Fragment_item item = (Listview_Fragment_item) l.getItemAtPosition(position) ;
// Listview_Fragment_item items = (Listview_Fragment_item) adapter.getItem(position);
String hos_name = item.getHos_name();
String hos_adress= item.getHos_adress();
String hos_review = item.getHos_review();
String hos_phone = item.getHos_phone();
String hos_day_time = item.getHos_day_time();
String hos_week_time = item.getHos_week_time();
Log.d("리스트 클릭", hos_phone);
Intent intent = new Intent(getActivity(),Clk_Fragment_list.class);
intent.putExtra("hos_name",hos_name);
intent.putExtra("hos_adress",hos_adress);
intent.putExtra("hos_review",hos_review);
intent.putExtra("hos_phone",hos_phone);
intent.putExtra("hos_day_time",hos_day_time);
intent.putExtra("hos_week_time",hos_week_time);
startActivity(intent);
// TODO : use item data.
}
이미지 버튼을 클릭했지만 listItem을 클릭하지 않았습니다.
답장을 보내 주셔서 감사합니다. "extends listfragment -> extends Fragment"라고 입력하면 코드로 변환하여 끝냈습니다. 그러나 여전히 항목을 클릭 할 수 없습니다. 나는 자바 코드가 문제가 아니라고 생각하지만, 여러개의 ImageView, ImageButton, RatingBar 등으로 구성되어있다. "list_item.xml"에 항목 클릭을 방해하는 요소가있는 것 같다. 도와 주셔서 대단히 감사합니다 :) –
No prob. :) ...... ...... – sargenexgen