|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Feb 2014
Città: Bergamo
Messaggi: 644
|
[android] LayoutInflater
Mi da il seguente errore
Codice:
android.view.InflateException: <merge /> can be used only with a valid ViewGroup root and attachToRoot=true at com.easlay.maptimer.CuoreAlly.onCreateView(CuoreAlly.java:18) Codice:
import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class CuoreEnemy extends Fragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = LayoutInflater.from(getActivity()).inflate(R.layout.activity_cuore2_timer, container, false); return v; } } Layout Codice:
<?xml version="1.0" encoding="utf-8"?> <merge > <include layout="@layout/activity_cuore"/> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> ...... </LinearLayout> </merge>
__________________
trattative concluse con : ipertotix, lele2004,Jeremy01,geminiII,antoniox,offdexter87,spedito83,francisco9751,Danny1 |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Feb 2014
Città: Bergamo
Messaggi: 644
|
up
__________________
trattative concluse con : ipertotix, lele2004,Jeremy01,geminiII,antoniox,offdexter87,spedito83,francisco9751,Danny1 |
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: Jul 2005
Città: Vicenza
Messaggi: 1570
|
Piuttosto che ottenere l'inflater da LayoutInflater.from hai provato ad usare direttamente l'inflater che ti viene passato come argomento dell'evento onCreateView?
Il pattern classico per gestire la creazione e gestione del layout del tuo fragment è proprio questo: Codice:
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_layout, container, false); // Configurazioni varie ed eventuali return view; } |
![]() |
![]() |
![]() |
#4 |
Senior Member
Iscritto dal: Feb 2014
Città: Bergamo
Messaggi: 644
|
purtroppo ci ho gia provato ma non riesco a risolvere.
Se gli passo xml senza il merge non genera errori
__________________
trattative concluse con : ipertotix, lele2004,Jeremy01,geminiII,antoniox,offdexter87,spedito83,francisco9751,Danny1 |
![]() |
![]() |
![]() |
#5 | |
Senior Member
Iscritto dal: Feb 2014
Città: Bergamo
Messaggi: 644
|
Quote:
Codice:
LinearLayout wrapper = new LinearLayout(getActivity()); // for example inflater.inflate(R.layout.activity_cuore2_timer, wrapper, true); return wrapper;
__________________
trattative concluse con : ipertotix, lele2004,Jeremy01,geminiII,antoniox,offdexter87,spedito83,francisco9751,Danny1 |
|
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 22:36.