Autore Topic: Problema con Fragment e immagini :(  (Letto 321 volte)

Offline simox2601

  • Nuovo arrivato
  • *
  • Post: 30
  • Respect: 0
    • Mostra profilo
  • Dispositivo Android:
    Galaxy S4
  • Sistema operativo:
    Windows
Problema con Fragment e immagini :(
« il: 05 Giugno 2014, 12:38:44 CEST »
0
Ciao a tutti!!

Ho un problema con l'app che sto sviluppando, nell'app utilizzo molte immagini (molto leggere) per mostrare scritte, icone ecc ecc; il problema è che spostandomi nelle varie pagine (che carico con i fragment) l'app va in crash. Non capisco a cosa sia dovuto, se alla quantita di immagini presenti nei vari fragment oppure al fatto che ogni fragment lo metto nel backstack. Ogni volta faccio cosi:

Codice (Java): [Seleziona]
FragmentManager manager = MainActivity.activity.getFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        Fragment nuova = new RegFragment();
        args.putBoolean("rate", rate);
        args.putString("dateReg", dateReg);
        nuova.setArguments(args);
        transaction.replace(R.id.content_frame, nuova, "REG_MENU").addToBackStack("REG_MENU");
        transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        transaction.commit();

mentre onBackPressed il codice è questo:

Codice (Java): [Seleziona]
FragmentManager manager = getFragmentManager();        
            if (manager.getBackStackEntryCount() > 0) {
                manager.popBackStack();
            } else if (manager.getBackStackEntryCount() == 0) {
                new AlertDialog.Builder(this)
                .setMessage("Vuoi chiudere l'applicazione?")
                .setPositiveButton("Si", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    finish();    
                }

            })
            .setNegativeButton("No", null)
            .show();
            }

L'errore che ho è il seguente:
Codice: [Seleziona]
06-05 12:37:09.189: E/AndroidRuntime(12758): Process: cmd.on4h, PID: 12758
06-05 12:37:09.189: E/AndroidRuntime(12758): android.view.InflateException: Binary XML file line #21: Error inflating class <unknown>
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.view.LayoutInflater.createView(LayoutInflater.java:626)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at cmd.on4h.diet.DietFragment.onCreateView(DietFragment.java:38)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.app.Fragment.performCreateView(Fragment.java:1700)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.app.BackStackRecord.run(BackStackRecord.java:684)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.os.Handler.handleCallback(Handler.java:733)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.os.Handler.dispatchMessage(Handler.java:95)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.os.Looper.loop(Looper.java:157)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.app.ActivityThread.main(ActivityThread.java:5356)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at java.lang.reflect.Method.invokeNative(Native Method)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at java.lang.reflect.Method.invoke(Method.java:515)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at dalvik.system.NativeStart.main(Native Method)
06-05 12:37:09.189: E/AndroidRuntime(12758): Caused by: java.lang.reflect.InvocationTargetException
06-05 12:37:09.189: E/AndroidRuntime(12758):         at java.lang.reflect.Constructor.constructNative(Native Method)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.view.LayoutInflater.createView(LayoutInflater.java:600)
06-05 12:37:09.189: E/AndroidRuntime(12758):         ... 25 more
06-05 12:37:09.189: E/AndroidRuntime(12758): Caused by: java.lang.OutOfMemoryError
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:677)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:507)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:872)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.content.res.Resources.loadDrawable(Resources.java:3024)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.view.View.<init>(View.java:3694)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.widget.TextView.<init>(TextView.java:897)
06-05 12:37:09.189: E/AndroidRuntime(12758):         at android.widget.TextView.<init>(TextView.java:892)
06-05 12:37:09.189: E/AndroidRuntime(12758):         ... 28 more


Sapete dirmi cosa può essere?

Grazie in anticipo