-1
도구 모음 이미지 뷰 이것은 내가 블로그, 힌트와 포럼의 버튼 클릭에 조각을 추가하는 fragmelayout를 포함하는 조각의 이미지입니다
clickabele 없습니다. 두 개의 이미지 뷰가있는 상단에 도구 모음 XML이 포함되어 있습니다. 문제는 버튼 클릭 수이지만 툴바 이미지 뷰 클릭 수는 포함되지 않습니다. 어떤 해결책?
도구 모음 :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
tools:ignore="MissingPrefix"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/header_gray"
android:focusable="true"
>
<ImageView
android:id="@+id/imgHomeToolbarBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:contentDescription="@string/app_name"
android:padding="10dp"
android:src="@drawable/left_arrow"
android:focusable="true"
/>
<TextView
android:id="@+id/txtHomeToolbarBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/imgHomeToolbarBack"
android:contentDescription="@string/app_name"
android:text="@string/edit"
android:textColor="@android:color/black"
android:textSize="@dimen/font_medium_semi"
fontPath="@string/font_regular"
/>
<TextView
android:id="@+id/txtHomeToolbarLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/app_name"
android:textColor="@android:color/black"
android:textSize="@dimen/text_size_20"
/>
<ImageView
android:id="@+id/imgHomeToolbarCalendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/dimen_margin_5"
android:contentDescription="@string/app_name"
android:padding="10dp"
android:src="@drawable/calender"
android:text="@string/next"
android:focusable="true"
android:textColor="@color/darkGrey"
android:textStyle="normal"
/>
</RelativeLayout>
</LinearLayout>
이 공통 도구 모음 코드입니다.
레이아웃 :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:ignore="MissingPrefix"
>
<include
layout="@layout/toolbar_home"
android:id="@+id/toolbar"
/>
<LinearLayout
android:id="@+id/llCommunitySections"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
>
<Button
android:id="@+id/btnBlog"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:text="@string/nabta_blog"
style="?android:attr/buttonBarButtonStyle"
fontPath="@string/font_regular"
android:textColor="@color/textDarkBlue"
/>
<Button
android:id="@+id/btnHints"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:text="@string/hints_tips"
style="?android:attr/buttonBarButtonStyle"
fontPath="@string/font_regular"
android:textColor="@color/blogGreyText"
/>
<Button
android:id="@+id/btnForums"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:text="@string/forums"
style="?android:attr/buttonBarButtonStyle"
fontPath="@string/font_regular"
android:textColor="@color/blogGreyText"
/>
</LinearLayout>
<FrameLayout
android:id="@+id/flCategories"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
onActivityCreated에 OnClickListener를 설정 한 후 내가 아이콘을 검색 아이콘을 클릭을 받고 있지만 다시하고 butterknife 주입의 insted. 일부 조각에서 뒤 아이콘의 가시성을 토글했습니다. 이것은 flCategories에로드하는 다른 조각이있는 조각입니다.
OnClickListener를의 코드 :
imgHomeToolbarBack.setOnClickListener(new View.OnClickListener()
{
@Override public void onClick(View v)
{
getChildFragmentManager().popBackStack();
}
});
imgHomeToolbarCalendar.setOnClickListener(new View.OnClickListener()
{
@Override public void onClick(View v)
{
Toast.makeText(getActivity(), "Search Clicked", Toast.LENGTH_SHORT).show();
}
});
토스트가 발생하는되어 있지만, 다른 하나.
일부 코드를 열람 할 수 있습니다. –
@AkshayKatariya 좀 보시기 바랍니다. –
클릭 청취자 용 자바 코드입니다. –