Click Event is not Fire when Naviation Drawer insrted in Xml file



I am working On Navigation Drawer in my android application.I insert Navigation Drawer widget in Relative layout,Navigation Drawer is working perfectly.But one problem is that I am not able to click on button which is in Relative layout. No event is fire on this Relative Layout .Could you tell me What should I do in code as well as Xml files.I am attached full source code here. Here is my xml code



<RelativeLayout
android:id="@+id/rel_right_gallery"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/alldeal_header"
android:layout_toRightOf="@+id/rel_gallery" >

<Button
android:id="@+id/btn_alldeals_up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:background="@drawable/nav_up" />


<Button
android:id="@+id/btn_all_deal_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_alldeal_vat"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:background="@drawable/more_btn" />

<TextView
android:id="@+id/txt_alldeal_vat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_alldeal_carprize"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="+VAT pcm "
android:textSize="20sp" />

<TextView
android:id="@+id/txt_alldeal_carprize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txt_cardesc"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:text="£257.99"
android:textColor="#00BFFF"
android:textSize="32sp" />

<Button
android:id="@+id/btn_all_deal_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btn_alldeals_up"
android:layout_below="@+id/btn_all_deal_more"
android:layout_marginTop="40dp"
android:background="@drawable/nav_down" />

<TextView
android:id="@+id/txt_cardesc"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txt_alldeal_vat"
android:layout_below="@+id/btn_alldeals_up"
android:layout_marginTop="15dp"
android:text="Mercedes c180 Exec SE Auto"
android:textSize="20sp" />


<RelativeLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/slidemenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"/>


</RelativeLayout>

</RelativeLayout>


Here is xml file for Navigation Drawer



<android.support.v4.widget.DrawerLayout
xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<FrameLayout
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>

<ListView
android:id="@+id/drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="#FFFFFF"
android:choiceMode="singleChoice"/>

</android.support.v4.widget.DrawerLayout>


Here is my java code



if(view==btn_search)
{
//mActivity.pushFragments(com.media.contractcar.base.AppConstants.TAB_HOME, new NavigationDrawer(), true, true);
// do your stuff
//mActivity.pushFragments(com.media.contractcar.base.AppConstants.TAB_HOME, new SlideMenu(), true, true);


Toast.makeText(mActivity, "Click on Search Button", Toast.LENGTH_LONG).show();

// you need to get instance of relative layout in hide it


//v.findViewById(R.id.)

ArrayAdapter<String> adapter = new ArrayAdapter<String>(mActivity, android.R.layout.simple_list_item_1, data);
final DrawerLayout drawer = (DrawerLayout)v.findViewById(R.id.drawer_layout);
final ListView navList = (ListView) v.findViewById(R.id.drawer);
navList.setAdapter(adapter);
navList.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view, final int pos,long id)
{
drawer.setDrawerListener( new DrawerLayout.SimpleDrawerListener(){
@SuppressLint("NewApi")
@Override
public void onDrawerClosed(View drawerView)
{
super.onDrawerClosed(drawerView);
/* AllDeals ad=new AllDeals();
mActivity.pushFragments(com.media.contractcar.base.AppConstants.TAB_HOME, ad, true, true);*/


}
});
drawer.closeDrawer(navList);
}
});
}

No comments:

Post a Comment