<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#color/colorMenuBg"
android:fitsSystemWindows="true"
android:maxWidth="268dp"
app:headerLayout="#layout/nav_header"
app:menu="#menu/nav_menu"
app:itemHorizontalPadding="28dp"
app:itemIconPadding="18dp"
app:itemIconSize="24dp"
app:itemIconTint="#drawable/drawer_item"
app:itemTextColor="#drawable/drawer_item">
Part of nav_menu:
<item
android:id="#+id/nav_videos"
android:icon="#drawable/cat_icon_videos"
android:checkable="true"
android:title="#string/all_videos"/>
<item
android:id="#+id/nav_pics"
android:icon="#drawable/cat_icon_gallery"
android:checkable="true"
android:title="#string/all_pics"/>
<item
android:id="#+id/nav_gifs"
android:icon="#drawable/cat_icon_gif"
android:checkable="true"
android:title="#string/all_gifs"/>
it's over 15 items
After selecting one item, the text of one or two unselected random items is becoming bold.
Any idea how to fix?
Maybe preventing it programmatically inside:
override fun onNavigationItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.nav_latest -> {
if (currentGal != "latest") {
getMemes("latest")
}
}
R.id.nav_top -> {
if (currentGal != "top") {
getMemes("top")
}
}
R.id.nav_random -> {
if (currentGal != "random") {
getMemes("random")
}
}
?
Thanks in adance
Related
I am using fragment and in that fragment i have ViewPager and in ViewPager i have added two fragments.when i open the app Everything works fine but my status bar becomes black and to see the icon i need to scroll down and this is happening in android 11,below android 11 Eveything working fine.now please let me know how to fix it...please don't ignore this and answer should be in Kotlin if Possible
I am attaching the code for it also
Main Activity:
class dashact : AppCompatActivity() {
lateinit var toolbar: Toolbar
lateinit var coordinator: CoordinatorLayout
lateinit var navigationdrawer: NavigationView
lateinit var drawerLayout: DrawerLayout
var nameofuser :String?="jdghjg"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.dashact)
toolbar = findViewById(R.id.toolbar)
coordinator = findViewById(R.id.coordinator)
navigationdrawer = findViewById(R.id.navigationview)
drawerLayout = findViewById(R.id.drawerlayout)
actionbar()
var toggle = ActionBarDrawerToggle(
this#dashact,
drawerLayout,
R.string.open,
R.string.close
)
toggle.syncState()
drawerLayout.addDrawerListener(toggle)
hideSystemBars()
navigtiontitle("home")
supportFragmentManager.beginTransaction()
.replace(R.id.frame, frag1())
.commit()
drawerLayout.closeDrawers()
navigationdrawer.setNavigationItemSelectedListener {
if (it.isChecked==true){
it.isCheckable=true
}else{
it.isCheckable=false
}
when (it.itemId) {
R.id.home -> {
navigtiontitle("home")
supportFragmentManager.beginTransaction()
.replace(R.id.frame, frag1())
.commit()
drawerLayout.closeDrawers()
}
R.id.fav ->{
navigtiontitle("Favourites")
supportFragmentManager.beginTransaction()
.replace(R.id.frame,Viewpager2())
.commit()
drawerLayout.closeDrawers()
}
R.id.privacy ->{
navigtiontitle("Privacy Policies")
supportFragmentManager.beginTransaction()
.replace(R.id.frame,privacy())
.commit()
drawerLayout.closeDrawers()
}
R.id.details ->{
navigtiontitle("My Details")
supportFragmentManager.beginTransaction()
.replace(R.id.frame,MyFrag())
.commit()
drawerLayout.closeDrawers()
}
}
return#setNavigationItemSelectedListener true
}
}
fun navigtiontitle(title: String) {
supportActionBar?.title = title
}
fun actionbar() {
super.setSupportActionBar(toolbar)
supportActionBar?.title = "Bookhub"
supportActionBar?.setHomeButtonEnabled(true)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
android.R.id.home -> drawerLayout.openDrawer(GravityCompat.START)
}
return super.onOptionsItemSelected(item)
}
fun hideSystemBars() {
val windowInsetsController =
ViewCompat.getWindowInsetsController(window.decorView) ?: return
// Configure the behavior of the hidden system bars
windowInsetsController.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
// Hide both the status bar and the navigation bar
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
}
}
xml of main activity:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawerlayout"
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"
>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:elevation="0dp" >
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
/>
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:id="#+id/frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
android:id="#+id/navigationview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:headerLayout="#layout/headers"
app:menu="#menu/icons"
android:layout_gravity="start"/>
</androidx.drawerlayout.widget.DrawerLayout>
themes.xml:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Test" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/purple_200</item> //for action bar
<item name="colorPrimaryVariant">#color/white</item> //can use to set status bar
<item name="colorOnPrimary">#color/purple_200</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/teal_200</item>
<item name="colorSecondaryVariant">#color/teal_700</item>
<item name="colorOnSecondary">#color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">#color/purple_200</item>
<!-- Customize your theme here. -->
</style>
<style name="splashs" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:windowBackground">#drawable/splash</item>
<item name="android:statusBarColor" tools:targetApi="l">#color/purple_200</item>
</style>
</resources>
You are hiding your system bars(status and navigation) in hideSystemBars() method. You are getting a black status bar probably due to a display cutout.
Find more about supporting display cutout here
my application has a menu of 3 options, and what I want is that according to a condition that I define, it shows only 2 options, or it shows 3.
I have tried all the options that I have found on google and here, but none have worked for me.
My idea is that as soon as the view is created, the menu already shows the options that it can show according to the condition. But as I have been able to achieve it, I added a button to simulate the event.
I would greatly appreciate your help.
Here I attach the code:
1) activity_home.xml (some part)
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:onClick="ActivarMenus"/>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:menu="#menu/home_menu"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" >
2) Aqui el archivo home_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/menu_item"
android:icon="#drawable/ic_baseline_more_vert_24"
app:showAsAction="ifRoom"
tools:ignore="MenuTitle">
<menu>
<item
android:id="#+id/newRegister"
android:icon="#drawable/ic_baseline_add_24"
app:showAsAction="always"
android:visible="true"
android:title="Nueva Orden Swab" />
<item
android:id="#+id/newAnexoo"
android:icon="#drawable/ic_baseline_add_24"
app:showAsAction="always"
android:visible="true"
android:title="Nuevo Formulario Anexo O" />
<item
android:id="#+id/sync"
android:icon="#drawable/ic_baseline_sync_24"
app:showAsAction="always"
android:visible="true"
android:title="Sincronizar" />
</menu>
</item>
</menu>
3) And a part of the HomeActivity.kt
class HomeActivity : ActivityViewBinding<ActivityHomeBinding, HomeVM>() {
private var mainMenu: Menu? = null
private lateinit var spm : SharedPreferencesManager
private val adapter: OrderAdapter by inject()
override fun inflateLayout(layoutInflater: LayoutInflater) =
ActivityHomeBinding.inflate(layoutInflater)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
//MenuMain.findItem(R.id.newAnexoo).isVisible = true
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
val inflater: MenuInflater = menuInflater
inflater.inflate(R.menu.home_menu, menu)
mainMenu = menu;
return true
}
fun ActivarMenus(view: View) {
mainMenu?.findItem(R.id.newRegister)?.isVisible = true
}
You should try this one it might be work.
if you want to change Menu Items at Run time You can use onPrepareOptionsMenu
#Override
public boolean onPrepareOptionsMenu(Menu menu){
if (//Your condition) {
menu.findItem(R.id.newRegister).setVisible(true);
}else {
menu.findItem(R.id.newRegister).setVisible(false);
}
return true;
}
I recently working on activating SearchView in ActionMode when user click on Search in onOptionsItemSelected.
However, I cant get access to the SearchView as after debugging, its actionView apparently to be null. Can anyone help me with this?
override fun onOptionsItemSelected(item: MenuItem): Boolean {
R.id.chat_search -> {
if (searchActionMode == null) {
searchActionMode = startActionMode(searchActionModeCallBack)
}
}
ActionModeCallBack
private val searchActionModeCallBack = object: ActionMode.Callback {
private lateinit var mSearchView: SearchView
override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_search_message, menu)
moreMenuBtn.isVisible = false
layout_chatbox.hide()
return true
}
override fun onPrepareActionMode(mode: ActionMode?, menu: Menu?): Boolean {
val searchItem = menu?.findItem(R.id.search_item_btn)
if(searchItem?.actionView != null) { <---- this seachview.actionView keeps return null
mSearchView = searchItem.actionView as SearchView
mSearchView.isIconified = false
mSearchView.onQueryTextChanged { newText ->
}
}
return true
}
override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean {
when(item?.itemId) {
R.id.search_item_up -> {
"UP".showToast(this#ChatActivity)
}
R.id.search_item_down -> {
"DOWN".showToast(this#ChatActivity)
}
R.id.search_item_btn -> {
"SEARCH".showToast(this#ChatActivity) <-- when click on "Search" Button, "Search" is toasted.
}
}
return false
}
override fun onDestroyActionMode(mode: ActionMode?) {
searchActionMode = null
moreMenuBtn.isVisible = true
layout_chatbox.show()
}
}
menu_search_message.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<group android:id="#+id/group_search_mode">
<item
android:id="#+id/search_item_btn"
android:icon="#drawable/ic_baseline_search_24"
app:showAsAction="always"
android:title="#string/search"
app:actionViewClass="androidx.appcompat.widget.SearchView" />
<item
android:id="#+id/search_item_up"
android:icon="#drawable/ic_baseline_arrow_drop_up_24"
app:showAsAction="always"
android:title="#string/up"/>
<item
android:id="#+id/search_item_down"
android:icon="#drawable/ic_baseline_arrow_drop_down_24"
app:showAsAction="always"
android:title="#string/down"/>
</group>
</menu>
I used androidx.appcompat.widget.SearchView for all of the SearchView I used. But still I had no idea why I can't access to the SearchView in ActionMode. Please give me some help.
I faced the same issue before, and what worked for me is to set the ActionView programmatically, not in menu xml.
To do that:
First: Remove the Action ViewClass from your menu
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<group android:id="#+id/group_search_mode">
<item
android:id="#+id/search_item_btn"
android:icon="#drawable/ic_baseline_search_24"
app:showAsAction="always"
android:title="#string/search"/>
...
Second: Create an instance of a SearchView
Third: Inflate the menu item that you want to set its actionViewClass, and use setActionView(view) to set your instantiated SearchView.
override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_search_message, menu)
moreMenuBtn.isVisible = false
layout_chatbox.hide()
// Step 2:
val searchView = SearchView(this)
searchView.setQuery(null, true)
searchView.queryHint = "Search"
// Step 3:
val searchItem = menu?.findItem(R.id.search_item_btn)
searchItem.setActionView(searchView)
return true
}
I had a workaround for this.
In my case, I will add a customview to the actionMode's title.
Here is my solution.
override fun onOptionsItemSelected(item: MenuItem): Boolean {
R.id.chat_search -> {
if (searchActionMode == null) {
searchActionMode = startActionMode(searchActionModeCallBack)
val view = layoutInflater.inflate(R.layout.custom_searchview, null)
searchActionMode?.customView = view <-- ADD YOUR CUSTOM VIEW
val etSearch = view.findViewById<EditText>(R.id.et_search)
etSearch.requestFocus()
etSearch.doOnTextChanged { text, start, before, count ->
// TODO - handle the search query here
}
}
}
custom_searchview.xml (Just a simple EditText)
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android" >
<EditText
android:id="#+id/et_search"
android:layout_alignParentStart="true"
android:maxLines="1"
android:ellipsize="end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:padding="10dp"
android:layout_marginEnd="50dp"
android:hint="Search..."
android:textColorHint="#color/colorWhite"
android:textColor="#color/colorWhite"/>
</RelativeLayout>
menu_search_message.xml (REMOVE THE SEARCH VIEW ITEM)
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- <item--> <-- remove the searchView from xml
<!-- android:id="#+id/search_item_btn"-->
<!-- android:icon="#drawable/ic_baseline_search_24"-->
<!-- android:title="#string/search"-->
<!-- android:enabled="true"-->
<!-- android:actionLayout="#layout/custom_searchview"-->
<!-- app:showAsAction="collapseActionView|always" />-->
<item
android:id="#+id/search_item_up"
android:icon="#drawable/ic_baseline_arrow_drop_up_24"
android:orderInCategory="2"
android:title="#string/up"
app:showAsAction="always" />
<item
android:id="#+id/search_item_down"
android:icon="#drawable/ic_baseline_arrow_drop_down_24"
android:orderInCategory="3"
android:title="#string/down"
app:showAsAction="always" />
</menu>
Final output will be like this
As in title - it looks correct until i click a button. It's happening only if i implement a listener. Here's the code:
Kotlin
navigationView.setNavigationItemSelectedListener{item ->
when (item.itemId) {
R.id.list_BT -> {
supportFragmentManager.beginTransaction().apply {
replace(R.id.fragmentContainer1, MenuFragment())
commit()
}
item.isChecked = true
}
R.id.info_BT -> {
supportFragmentManager.beginTransaction().apply {
replace(R.id.fragmentContainer1, AboutFragment())
commit()
}
item.isChecked = true
}
R.id.preferences_BT -> {
val intent = Intent(applicationContext, OptionsActivity::class.java)
startActivity(intent)
}
}
true
}
XML - Activity
<com.google.android.material.navigation.NavigationView
android:id="#+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="#menu/drawer_menu"
app:headerLayout="#layout/drawer_header"
android:clipChildren="false"
android:theme="#style/Theme.JaBotMobile.Drawer"/>
XML - theme (kinda simple 4 now)
<style name="Theme.Base.JaBotMobile.Drawer">
<item name="fontFamily">#font/open_sans_regular</item>
</style>
<style name="Theme.JaBotMobile.Drawer" parent="Theme.Base.JaBotMobile.Drawer" />
Ok, I've found a solution thanks to #johnnyzen on GitHub. Thanks #ashu for pointing me to the source of the problem.
Make sure NavigationView DOES NOT use:
android:theme="#style/MyCustomNavStyle"
but use:
app:itemTextAppearance="#style/MyCustomNavStyle"
#font/montserrat_regular
I am developing an android app and am new to programming. I have extended the base drawer activity to all activity. But after I clicked the menu button of the drawer in the activities that extend drawer activity, nothing happened. Below is my code in the base drawer activity.
open class DrawerActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelectedListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.requestWindowFeature(Window.FEATURE_NO_TITLE)
this.window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
setContentView(R.layout.activity_drawer)
setSupportActionBar(toolbar)
nav_view.setNavigationItemSelectedListener(this)
pageToGo = 1
println("PageToGo on start activity: $pageToGo")
}
override fun onBackPressed() {
println("Back is pressed")
if (drawer_layout.isDrawerOpen(GravityCompat.END)) {
drawer_layout.closeDrawer(GravityCompat.END)
} else {
finishAffinity()
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
// Inflate the menu; this adds items to the action bar if it is present.
menuInflater.inflate(R.menu.drawer, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
when (item.itemId) {
R.id.action_settings -> return true
else -> return super.onOptionsItemSelected(item)
}
}
override fun onNavigationItemSelected(item: MenuItem): Boolean {
// Handle navigation view item clicks here.
when (item.itemId) {
R.id.nav_show_stat -> {
println("I am clicked")
}
R.id.nav_restart_game -> {
}
R.id.nav_achievements -> {
}
R.id.nav_settings -> {
}
R.id.nav_about_us -> {
}
R.id.nav_contact_us -> {
}
}
drawer_layout.closeDrawer(GravityCompat.END)
return true
}
override fun setContentView(layoutResID:Int) {
val fullLayout: DrawerLayout
val actContent: FrameLayout
fullLayout = layoutInflater.inflate(R.layout.activity_drawer, null) as DrawerLayout
actContent = fullLayout.findViewById(R.id.act_content) as FrameLayout
layoutInflater.inflate(layoutResID, actContent, true)
super.setContentView(fullLayout)
}
Below is my drawer_layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="end">
<include
layout="#layout/app_bar_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="#+id/act_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_drawer"
app:menu="#menu/activity_drawer_drawer">
</android.support.design.widget.NavigationView>
Below is my menu code
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_show_stat"
android:icon="#drawable/ic_menu_camera"
android:title="#string/nav_show_stat" />
<item
android:id="#+id/nav_restart_game"
android:icon="#drawable/ic_menu_gallery"
android:title="#string/nav_restart" />
<item
android:id="#+id/nav_achievements"
android:icon="#drawable/ic_menu_slideshow"
android:title="#string/nav_achievements" />
<item
android:id="#+id/nav_settings"
android:icon="#drawable/ic_menu_manage"
android:title="#string/nav_settings" />
</group>
<item android:title="#string/nav_our_company">
<menu>
<item
android:id="#+id/nav_about_us"
android:icon="#drawable/ic_menu_share"
android:title="#string/nav_about_us" />
<item
android:id="#+id/nav_contact_us"
android:icon="#drawable/ic_menu_send"
android:title="#string/nav_contact_us" />
</menu>
</item>
Below is my code in main activity
class MainActivity : DrawerActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
load()
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
beginAdventure()
main_layout.setOnTouchListener(object : OnSwipeTouchListener(applicationContext) {
override fun onSwipeLeft() {
drawer_layout.openDrawer(GravityCompat.END)
}
})
}
private fun beginAdventure() {
start_game_btn.setSafeOnClickListener {
nextPage("ChapterOneActOneActivity", 1)
}
}
}
I know I am missing something important. But I just don't know what it is. The onNavigationItemSelected seems not working because when I click on R.id.nav_show_stat, "I am clicked" never gets printed. Please kindly let me know what I should do to make the drawer buttons work in all activity. Thank you in advance.
Edit2: my drawer in main activity
https://imgur.com/a/ofGzncZ
So when I click on Show Statistics, the "I am clicked" is never printed. How do I handle the click event to do what I want?
No need to use the below given code separately :-
override fun setContentView(layoutResID:Int) {
val fullLayout: DrawerLayout
val actContent: FrameLayout
fullLayout = layoutInflater.inflate(R.layout.activity_drawer, null) as DrawerLayout
actContent = fullLayout.findViewById(R.id.act_content) as FrameLayout
layoutInflater.inflate(layoutResID, actContent, true)
super.setContentView(fullLayout)
}
just add :-
setContentView(R.layout.your_layout_filename);
i think there is no other issue in your code