2016-05-19 5 views
0

I ListFragment mit mehreren Karten, mit einem benutzerdefinierten DialogFragment. Es zeigt einen Fehler. Ich bin stecken mir dort helfenVerwenden von ListFragment in einem benutzerdefinierten Dialogfeld haben Problem und zeigen Fehler beim Auffüllen Klasse Fragment

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/sky_blue" 
    android:orientation="vertical"> 

    <TextView 
     android:id="@+id/upcomingShifts" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:textColor="@color/black" 
     android:textSize="@dimen/text_size_24sp" 
     android:padding="@dimen/padding_10dp" 
     android:text="@string/upcoming_shifts"/> 
    <FrameLayout 
     android:id="@+id/frameLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <fragment 
      android:id="@+id/lvMapFragment" 
      class="android.support.v4.app.ListFragment" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 

    </FrameLayout> 

</LinearLayout> 

Hier ist meine benutzerdefinierten Dialog Code

@Override 

    protected Dialog onCreateDialogPost(Bundle savedInstanceState) { 
     dialog = new Dialog(getActivity(), R.style.AppDialogTheme); 
     dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
     dialog.setContentView(R.layout.activity_up_coming_shift); 
     WindowManager windowManager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); 
     dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 
//  dialog.getWindow().getAttributes().windowAnimations = R.style.AppDialogPullAnimation; 
     WindowManager.LayoutParams layoutParams = dialog.getWindow().getAttributes(); 
     Display display = windowManager.getDefaultDisplay(); 
     Point point = new Point(); 
     display.getSize(point); 
     int width = point.x - 40; 
     layoutParams.gravity = Gravity.TOP | Gravity.LEFT; 
     dialog.getWindow().setLayout(width, ViewGroup.LayoutParams.MATCH_PARENT); 
     dialog.setCancelable(true); 
     init(); 
     return dialog; 
    } 
+0

zeigen Sie den Code in dem Sie das Layout aufzublasen und auch das Fehlerprotokoll. – ishmaelMakitla

+0

bitte auch Fehler melden. – Sush

+0

android.view.InflateException: Binär XML-Dateizeile # 23: Fehler beim Aufblasen des Klassenfragments –

Antwort

-1

Sie können versuchen, das Layout zu ändern.

Ihr Code:

<fragment 
     android:id="@+id/lvMapFragment" 
     class="android.support.v4.app.ListFragment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

Neuer Code:

<fragment 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:name="package_name_of_your_class_that_extends_ListFragment" 
      android:id="@+id/lvMapFragment" 
      tools:layout="@layout/name_of_your_layout_use_in_above_class" 
      /> 
+0

es funktioniert nicht in meinem Fall, weil ich listfragment nicht erweitert –

Verwandte Themen