android - click on empty space in fragment executes activity event -
i have activity consists of 4 images , onclick of image i'm opening fragment. also, have navigation drawer profile option opens fragment. since fields in profilefragment few there allot of empty space. , if user clicks on empty space, click event of image placed in activity executed , particular fragment opens up. have tried set background color of profilefragment white, did not work.
profilefragment class :
public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment view view = inflater.inflate(r.layout.fragment_profile, container, false); butterknife.bind(this, view); view.setbackgroundcolor(color.white); return view; } profile_fragment.xml
<framelayout 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" tools:context="com.six30labs.mis.fragments.profilefragment"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <edittext android:id="@+id/empcompanyname" style="@style/mytextviewstyle" android:hint="company name" android:inputtype="text" /> <edittext android:id="@+id/empphonenumber" style="@style/mytextviewstyle" android:hint="employee phno" android:inputtype="text" /> <edittext android:id="@+id/empemail" style="@style/mytextviewstyle" android:hint="employee email" android:inputtype="text" /> <button android:id="@+id/editprofilebtn" android:text="edit" android:layout_width="match_parent" android:layout_height="wrap_content" /> </linearlayout> </framelayout> on click of profile option in navigation drawer i'm using following line open fragment :
fragment = new profilefragment(); getsupportfragmentmanager().begintransaction().replace(r.id.container_view,fragment).addtobackstack("profile").commit(); how fix issue? kindly me out please..
write code in root layout of fragment
android:clickable="true" in case framelayout
<framelayout 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:clickable="true" tools:context="com.six30labs.mis.fragments.profilefragment">
Comments
Post a Comment