2014-08-30 3 views
0

문제를 설명하는 것이 약간 어렵다고 생각하지만 시도하겠습니다. 여기에 클래스 코드안드로이드 프로그래밍의 단편

@Override 
public View onCreateView(LayoutInflater inflater, 
     ViewGroup container, Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
     rootView = inflater.inflate(R.layout.search_doctor, container, false); 

    spinnerCity = (Spinner) rootView.findViewById(R.id.cityList); 

클래스는 괜찮아요라고 처음의 한 부분이다 나는 조각을 확장하는 클래스를하고 난 추적 코드

frag = new SearchDoctor(); 
      fragTransaction = getFragmentManager().beginTransaction().replace(R.id.container, frag); 
      fragTransaction.commit(); 

로 부른다. 하지만 다음 번에 "rootView = inflater.inflate (R.layout.search_doctor, container, false);"라인에서 thead exit라고 부릅니다. "

다른 레이아웃으로 여러 번 시도했기 때문에 search_doctor.xml (레이아웃)에 포함 된 조각에 문제가 있다는 것을 알고 있습니다. 문제가 발생했습니다. 여기

는 레이아웃 search_doctor.xml 누군가가 나를 도울 수 있다면

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <Spinner 
     android:id="@+id/cityList" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:entries="@array/city_arrays" 
     android:prompt="@string/city_prompt" /> 

    <Button 
     android:id="@+id/btnSearch" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_below="@+id/specialtyList" 
     android:layout_marginRight="16dp" 
     android:text="Αναζήτηση" /> 

    <Spinner 
     android:id="@+id/specialtyList" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/cityList" 
     android:entries="@array/specialty_arrays" 
     android:prompt="@string/specialty_prompt" /> 

    <fragment 
     android:id="@+id/map" 
     android:name="com.google.android.gms.maps.MapFragment" 
     android:layout_width="match_parent" 
     android:layout_height="100dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/btnSearch" 
     android:layout_marginTop="22dp" 
     class="com.google.android.gms.maps.SupportMapFragment" /> 

    <ListView 
     android:id="@+id/resultList" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@+id/btnSearch" 
     android:layout_marginTop="22dp" > 

    </ListView> 

    <Button 
     android:id="@+id/btnMap" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/resultList" 
     android:layout_alignParentLeft="true" 
     android:layout_marginLeft="16dp" 
     android:text="Χάρτης" /> 

</RelativeLayout> 

나는 매우 기쁨을 드리겠습니다에게 있습니다. 미리 감사드립니다. 뷰 계층 구조에 문제가 유용 할 수 있습니다 그 경우

+0

onCreateView()를 호출 하시겠습니까? – ChiefTwoPencils

+0

@ChiefTwoPencils 나는 그것을 부르고 그것을 실행 중이다. 내가 쓴 것처럼 문제는 xml 파일의 단편에있다. –

+0

수동으로 oncreateview를 호출한다고 하시겠습니까? – Breadbin

답변

0

이것은 해결책입니다! 나는 포럼에서 찾았습니다. 여러분 모두에게 감사드립니다.

public void onDestroyView() 
{ 
    super.onDestroyView(); 
    Fragment fragment = (getFragmentManager().findFragmentById(R.id.map)); 
    FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); 
    ft.remove(fragment); 
    ft.commit(); 
} 
-1

당신이 도움이된다면

rootView = inflater.inflate(R.layout.search_doctor, null, false); 

확실하지 않음으로

rootView = inflater.inflate(R.layout.search_doctor, container, false); 

을 대체하려고하지만 수 있습니다.

+0

컨테이너 대신 null을 추가하면 조각 대체시 또는 framelayout에 추가 될 때 충돌합니다. – DaxeshKhatri

+0

@Andrii Gorishnii 시도했지만 문제가 계속됩니다. –

관련 문제