PlaceAutocomplete inside Navigation Drawer












0















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 '18 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 '18 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 '18 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 '18 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 '18 at 1:36
















0















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 '18 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 '18 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 '18 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 '18 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 '18 at 1:36














0












0








0








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 '18 at 1:01







Jurgiele

















asked Nov 20 '18 at 0:15









JurgieleJurgiele

358




358








  • 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 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 '18 at 1:36












1 Answer
1






active

oldest

votes


















0














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',
    autoActivateHeartbeat: false,
    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









    0














    I should implement PlaceSelectionListener inside MainActivity not in fragment.






    share|improve this answer




























      0














      I should implement PlaceSelectionListener inside MainActivity not in fragment.






      share|improve this answer


























        0












        0








        0







        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 '18 at 1:39









        JurgieleJurgiele

        358




        358
































            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.




            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

            鏡平學校

            ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

            Why https connections are so slow when debugging (stepping over) in Java?