PlaceAutocomplete inside Navigation Drawer











up vote
0
down vote

favorite












I'm trying to put PlaceAutocomplete inside Navigation Drawer. Also any project with placeautocomplete api posted on github can be an answer or any source how to make custom nav drawer with placeautocomplete



Here is my code:



Search fragment layout:



<FrameLayout
android:id="@+id/autocompleteHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/customViewPager"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<fragment
android:id="@+id/autocomplete_fragment"
android:name="com.x.egerg.fragments.AutoComplete"
android:layout_width="match_parent"
android:layout_height="wrap_content" />



DrawerLayout



    <include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/searchfraglay"
app:menu="@menu/activity_main_drawer" />

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


AutoComplete fragment



class AutoComplete : Fragment(), PlaceSelectionListener {
override fun onCreate(savedInstanceState: Bundle?) {
val autocompleteFragment = fragmentManager!!.findFragmentById(R.id.autocomplete_fragment) as SupportPlaceAutocompleteFragment
autocompleteFragment.setOnPlaceSelectedListener(this)
super.onCreate(savedInstanceState)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {

return inflater.inflate(R.layout.searchfraglay, container, false)
}


override fun onPlaceSelected(p0: Place?) {
Log.d("OnPlaceSelected", p0?.name.toString())
}

override fun onError(p0: Status?) {
Log.d("OnPlaceSelected", "error")

}


}



inside MainActivity



nav_view.inflateHeaderView(R.layout.searchfraglay)

val ft = supportFragmentManager.beginTransaction()
ft.replace(R.id.autocompleteHolder, AutoComplete())
ft.commit()


Logcat



java.lang.RuntimeException: Unable to start activity ComponentInfo{com.x.egerg/com.x.egerg.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
Caused by: java.lang.ClassCastException: com.x.egerg.fragments.AutoComplete cannot be cast to com.google.android.gms.location.places.ui.SupportPlaceAutocompleteFragment
at com.x.egerg.fragments.AutoComplete.onCreate(AutoComplete.kt:30)
xxx
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:211)
at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:267)
at com.x.egerg.MainActivity.onCreate(MainActivity.kt:21)









share|improve this question




















  • 1




    The first argument passed in the replace() call is the ID for the ViewGroup – e.g., an empty FrameLayout – that the Fragment's View will be placed into. I don't see anything in your Activity's layout with ID autocompleteHolder1. Should it be in app_bar_main?
    – Mike M.
    Nov 20 at 0:19












  • @MikeM. autocompleteHolder is placed in search layout which is header layout of DrawerLayout. What should I do in this situation?
    – Jurgiele
    Nov 20 at 0:26






  • 1




    Ah, that's what you mean. It's not always clear what users mean by Navigation Drawer, exactly. Hmm, you might have to set that header programmatically, rather than with the headerLayout XML attribute. NavigationView takes a bit to get itself setup, and the header Views are not going to be available right away, when it's set in the layout. Try removing that headerLayout, and using NavigationView#inflateHeaderView() instead, before your FragmentTransaction. I'm not sure if that'll work, though, as I'm not sure when that header actually gets attached to the Activity's hierarchy.
    – Mike M.
    Nov 20 at 0:34






  • 1




    I'm getting a little confused, now. What is searchfraglay, exactly? If that's what you have labelled as "Search fragment layout:", why are you trying to set it as a header, and using it as the layout for AutoComplete? Also, which Fragment is supposed to be in the header, AutoComplete or SupportPlaceAutocompleteFragment?
    – Mike M.
    Nov 20 at 1:13






  • 1




    Solved, it should be implemented in MainActivity. Sorry for wasting your time guys, I didn't check simplest way to do it. Thanks a lot for your time @MikeM.
    – Jurgiele
    Nov 20 at 1:36















up vote
0
down vote

favorite












I'm trying to put PlaceAutocomplete inside Navigation Drawer. Also any project with placeautocomplete api posted on github can be an answer or any source how to make custom nav drawer with placeautocomplete



Here is my code:



Search fragment layout:



<FrameLayout
android:id="@+id/autocompleteHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/customViewPager"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<fragment
android:id="@+id/autocomplete_fragment"
android:name="com.x.egerg.fragments.AutoComplete"
android:layout_width="match_parent"
android:layout_height="wrap_content" />



DrawerLayout



    <include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/searchfraglay"
app:menu="@menu/activity_main_drawer" />

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


AutoComplete fragment



class AutoComplete : Fragment(), PlaceSelectionListener {
override fun onCreate(savedInstanceState: Bundle?) {
val autocompleteFragment = fragmentManager!!.findFragmentById(R.id.autocomplete_fragment) as SupportPlaceAutocompleteFragment
autocompleteFragment.setOnPlaceSelectedListener(this)
super.onCreate(savedInstanceState)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {

return inflater.inflate(R.layout.searchfraglay, container, false)
}


override fun onPlaceSelected(p0: Place?) {
Log.d("OnPlaceSelected", p0?.name.toString())
}

override fun onError(p0: Status?) {
Log.d("OnPlaceSelected", "error")

}


}



inside MainActivity



nav_view.inflateHeaderView(R.layout.searchfraglay)

val ft = supportFragmentManager.beginTransaction()
ft.replace(R.id.autocompleteHolder, AutoComplete())
ft.commit()


Logcat



java.lang.RuntimeException: Unable to start activity ComponentInfo{com.x.egerg/com.x.egerg.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
Caused by: java.lang.ClassCastException: com.x.egerg.fragments.AutoComplete cannot be cast to com.google.android.gms.location.places.ui.SupportPlaceAutocompleteFragment
at com.x.egerg.fragments.AutoComplete.onCreate(AutoComplete.kt:30)
xxx
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:211)
at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:267)
at com.x.egerg.MainActivity.onCreate(MainActivity.kt:21)









share|improve this question




















  • 1




    The first argument passed in the replace() call is the ID for the ViewGroup – e.g., an empty FrameLayout – that the Fragment's View will be placed into. I don't see anything in your Activity's layout with ID autocompleteHolder1. Should it be in app_bar_main?
    – Mike M.
    Nov 20 at 0:19












  • @MikeM. autocompleteHolder is placed in search layout which is header layout of DrawerLayout. What should I do in this situation?
    – Jurgiele
    Nov 20 at 0:26






  • 1




    Ah, that's what you mean. It's not always clear what users mean by Navigation Drawer, exactly. Hmm, you might have to set that header programmatically, rather than with the headerLayout XML attribute. NavigationView takes a bit to get itself setup, and the header Views are not going to be available right away, when it's set in the layout. Try removing that headerLayout, and using NavigationView#inflateHeaderView() instead, before your FragmentTransaction. I'm not sure if that'll work, though, as I'm not sure when that header actually gets attached to the Activity's hierarchy.
    – Mike M.
    Nov 20 at 0:34






  • 1




    I'm getting a little confused, now. What is searchfraglay, exactly? If that's what you have labelled as "Search fragment layout:", why are you trying to set it as a header, and using it as the layout for AutoComplete? Also, which Fragment is supposed to be in the header, AutoComplete or SupportPlaceAutocompleteFragment?
    – Mike M.
    Nov 20 at 1:13






  • 1




    Solved, it should be implemented in MainActivity. Sorry for wasting your time guys, I didn't check simplest way to do it. Thanks a lot for your time @MikeM.
    – Jurgiele
    Nov 20 at 1:36













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to put PlaceAutocomplete inside Navigation Drawer. Also any project with placeautocomplete api posted on github can be an answer or any source how to make custom nav drawer with placeautocomplete



Here is my code:



Search fragment layout:



<FrameLayout
android:id="@+id/autocompleteHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/customViewPager"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<fragment
android:id="@+id/autocomplete_fragment"
android:name="com.x.egerg.fragments.AutoComplete"
android:layout_width="match_parent"
android:layout_height="wrap_content" />



DrawerLayout



    <include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/searchfraglay"
app:menu="@menu/activity_main_drawer" />

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


AutoComplete fragment



class AutoComplete : Fragment(), PlaceSelectionListener {
override fun onCreate(savedInstanceState: Bundle?) {
val autocompleteFragment = fragmentManager!!.findFragmentById(R.id.autocomplete_fragment) as SupportPlaceAutocompleteFragment
autocompleteFragment.setOnPlaceSelectedListener(this)
super.onCreate(savedInstanceState)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {

return inflater.inflate(R.layout.searchfraglay, container, false)
}


override fun onPlaceSelected(p0: Place?) {
Log.d("OnPlaceSelected", p0?.name.toString())
}

override fun onError(p0: Status?) {
Log.d("OnPlaceSelected", "error")

}


}



inside MainActivity



nav_view.inflateHeaderView(R.layout.searchfraglay)

val ft = supportFragmentManager.beginTransaction()
ft.replace(R.id.autocompleteHolder, AutoComplete())
ft.commit()


Logcat



java.lang.RuntimeException: Unable to start activity ComponentInfo{com.x.egerg/com.x.egerg.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
Caused by: java.lang.ClassCastException: com.x.egerg.fragments.AutoComplete cannot be cast to com.google.android.gms.location.places.ui.SupportPlaceAutocompleteFragment
at com.x.egerg.fragments.AutoComplete.onCreate(AutoComplete.kt:30)
xxx
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:211)
at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:267)
at com.x.egerg.MainActivity.onCreate(MainActivity.kt:21)









share|improve this question















I'm trying to put PlaceAutocomplete inside Navigation Drawer. Also any project with placeautocomplete api posted on github can be an answer or any source how to make custom nav drawer with placeautocomplete



Here is my code:



Search fragment layout:



<FrameLayout
android:id="@+id/autocompleteHolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/customViewPager"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<fragment
android:id="@+id/autocomplete_fragment"
android:name="com.x.egerg.fragments.AutoComplete"
android:layout_width="match_parent"
android:layout_height="wrap_content" />



DrawerLayout



    <include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/searchfraglay"
app:menu="@menu/activity_main_drawer" />

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


AutoComplete fragment



class AutoComplete : Fragment(), PlaceSelectionListener {
override fun onCreate(savedInstanceState: Bundle?) {
val autocompleteFragment = fragmentManager!!.findFragmentById(R.id.autocomplete_fragment) as SupportPlaceAutocompleteFragment
autocompleteFragment.setOnPlaceSelectedListener(this)
super.onCreate(savedInstanceState)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {

return inflater.inflate(R.layout.searchfraglay, container, false)
}


override fun onPlaceSelected(p0: Place?) {
Log.d("OnPlaceSelected", p0?.name.toString())
}

override fun onError(p0: Status?) {
Log.d("OnPlaceSelected", "error")

}


}



inside MainActivity



nav_view.inflateHeaderView(R.layout.searchfraglay)

val ft = supportFragmentManager.beginTransaction()
ft.replace(R.id.autocompleteHolder, AutoComplete())
ft.commit()


Logcat



java.lang.RuntimeException: Unable to start activity ComponentInfo{com.x.egerg/com.x.egerg.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment
Caused by: java.lang.ClassCastException: com.x.egerg.fragments.AutoComplete cannot be cast to com.google.android.gms.location.places.ui.SupportPlaceAutocompleteFragment
at com.x.egerg.fragments.AutoComplete.onCreate(AutoComplete.kt:30)
xxx
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:211)
at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:267)
at com.x.egerg.MainActivity.onCreate(MainActivity.kt:21)






java android kotlin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 1:01

























asked Nov 20 at 0:15









Jurgiele

237




237








  • 1




    The first argument passed in the replace() call is the ID for the ViewGroup – e.g., an empty FrameLayout – that the Fragment's View will be placed into. I don't see anything in your Activity's layout with ID autocompleteHolder1. Should it be in app_bar_main?
    – Mike M.
    Nov 20 at 0:19












  • @MikeM. autocompleteHolder is placed in search layout which is header layout of DrawerLayout. What should I do in this situation?
    – Jurgiele
    Nov 20 at 0:26






  • 1




    Ah, that's what you mean. It's not always clear what users mean by Navigation Drawer, exactly. Hmm, you might have to set that header programmatically, rather than with the headerLayout XML attribute. NavigationView takes a bit to get itself setup, and the header Views are not going to be available right away, when it's set in the layout. Try removing that headerLayout, and using NavigationView#inflateHeaderView() instead, before your FragmentTransaction. I'm not sure if that'll work, though, as I'm not sure when that header actually gets attached to the Activity's hierarchy.
    – Mike M.
    Nov 20 at 0:34






  • 1




    I'm getting a little confused, now. What is searchfraglay, exactly? If that's what you have labelled as "Search fragment layout:", why are you trying to set it as a header, and using it as the layout for AutoComplete? Also, which Fragment is supposed to be in the header, AutoComplete or SupportPlaceAutocompleteFragment?
    – Mike M.
    Nov 20 at 1:13






  • 1




    Solved, it should be implemented in MainActivity. Sorry for wasting your time guys, I didn't check simplest way to do it. Thanks a lot for your time @MikeM.
    – Jurgiele
    Nov 20 at 1:36














  • 1




    The first argument passed in the replace() call is the ID for the ViewGroup – e.g., an empty FrameLayout – that the Fragment's View will be placed into. I don't see anything in your Activity's layout with ID autocompleteHolder1. Should it be in app_bar_main?
    – Mike M.
    Nov 20 at 0:19












  • @MikeM. autocompleteHolder is placed in search layout which is header layout of DrawerLayout. What should I do in this situation?
    – Jurgiele
    Nov 20 at 0:26






  • 1




    Ah, that's what you mean. It's not always clear what users mean by Navigation Drawer, exactly. Hmm, you might have to set that header programmatically, rather than with the headerLayout XML attribute. NavigationView takes a bit to get itself setup, and the header Views are not going to be available right away, when it's set in the layout. Try removing that headerLayout, and using NavigationView#inflateHeaderView() instead, before your FragmentTransaction. I'm not sure if that'll work, though, as I'm not sure when that header actually gets attached to the Activity's hierarchy.
    – Mike M.
    Nov 20 at 0:34






  • 1




    I'm getting a little confused, now. What is searchfraglay, exactly? If that's what you have labelled as "Search fragment layout:", why are you trying to set it as a header, and using it as the layout for AutoComplete? Also, which Fragment is supposed to be in the header, AutoComplete or SupportPlaceAutocompleteFragment?
    – Mike M.
    Nov 20 at 1:13






  • 1




    Solved, it should be implemented in MainActivity. Sorry for wasting your time guys, I didn't check simplest way to do it. Thanks a lot for your time @MikeM.
    – Jurgiele
    Nov 20 at 1:36








1




1




The first argument passed in the replace() call is the ID for the ViewGroup – e.g., an empty FrameLayout – that the Fragment's View will be placed into. I don't see anything in your Activity's layout with ID autocompleteHolder1. Should it be in app_bar_main?
– Mike M.
Nov 20 at 0:19






The first argument passed in the replace() call is the ID for the ViewGroup – e.g., an empty FrameLayout – that the Fragment's View will be placed into. I don't see anything in your Activity's layout with ID autocompleteHolder1. Should it be in app_bar_main?
– Mike M.
Nov 20 at 0:19














@MikeM. autocompleteHolder is placed in search layout which is header layout of DrawerLayout. What should I do in this situation?
– Jurgiele
Nov 20 at 0:26




@MikeM. autocompleteHolder is placed in search layout which is header layout of DrawerLayout. What should I do in this situation?
– Jurgiele
Nov 20 at 0:26




1




1




Ah, that's what you mean. It's not always clear what users mean by Navigation Drawer, exactly. Hmm, you might have to set that header programmatically, rather than with the headerLayout XML attribute. NavigationView takes a bit to get itself setup, and the header Views are not going to be available right away, when it's set in the layout. Try removing that headerLayout, and using NavigationView#inflateHeaderView() instead, before your FragmentTransaction. I'm not sure if that'll work, though, as I'm not sure when that header actually gets attached to the Activity's hierarchy.
– Mike M.
Nov 20 at 0:34




Ah, that's what you mean. It's not always clear what users mean by Navigation Drawer, exactly. Hmm, you might have to set that header programmatically, rather than with the headerLayout XML attribute. NavigationView takes a bit to get itself setup, and the header Views are not going to be available right away, when it's set in the layout. Try removing that headerLayout, and using NavigationView#inflateHeaderView() instead, before your FragmentTransaction. I'm not sure if that'll work, though, as I'm not sure when that header actually gets attached to the Activity's hierarchy.
– Mike M.
Nov 20 at 0:34




1




1




I'm getting a little confused, now. What is searchfraglay, exactly? If that's what you have labelled as "Search fragment layout:", why are you trying to set it as a header, and using it as the layout for AutoComplete? Also, which Fragment is supposed to be in the header, AutoComplete or SupportPlaceAutocompleteFragment?
– Mike M.
Nov 20 at 1:13




I'm getting a little confused, now. What is searchfraglay, exactly? If that's what you have labelled as "Search fragment layout:", why are you trying to set it as a header, and using it as the layout for AutoComplete? Also, which Fragment is supposed to be in the header, AutoComplete or SupportPlaceAutocompleteFragment?
– Mike M.
Nov 20 at 1:13




1




1




Solved, it should be implemented in MainActivity. Sorry for wasting your time guys, I didn't check simplest way to do it. Thanks a lot for your time @MikeM.
– Jurgiele
Nov 20 at 1:36




Solved, it should be implemented in MainActivity. Sorry for wasting your time guys, I didn't check simplest way to do it. Thanks a lot for your time @MikeM.
– Jurgiele
Nov 20 at 1:36












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










I should implement PlaceSelectionListener inside MainActivity not in fragment.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384457%2fplaceautocomplete-inside-navigation-drawer%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote



    accepted










    I should implement PlaceSelectionListener inside MainActivity not in fragment.






    share|improve this answer

























      up vote
      0
      down vote



      accepted










      I should implement PlaceSelectionListener inside MainActivity not in fragment.






      share|improve this answer























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        I should implement PlaceSelectionListener inside MainActivity not in fragment.






        share|improve this answer












        I should implement PlaceSelectionListener inside MainActivity not in fragment.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 at 1:39









        Jurgiele

        237




        237






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384457%2fplaceautocomplete-inside-navigation-drawer%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            To store a contact into the json file from server.js file using a class in NodeJS

            Redirect URL with Chrome Remote Debugging Android Devices

            Dieringhausen