나는 조각 내부의 슬라이드 쇼를 만들려고하지만 난 자바 코드 내부 뷰를 정의하려고 할 때이 오류가 : 여기오류 : 팽창 클래스 단편
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.nir.nestleapp, PID: 25042
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.nir.nestleapp/com.example.nir.nestleapp.MainPageActivity}: android.view.InflateException: Binary XML file line #37: Binary XML file line #37: Error inflating class fragment
는 자바 코드는 다음과 같습니다
나는 많은 솔루션 아무것도가 보인다 시도했다<FrameLayout 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"
class="com.fragment.NavigationDrawerFragment"
tools:context="com.example.nir.nestleapp.SlideshowFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/SlideshowFragmentpage"></RelativeLayout>
<ViewFlipper
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/backgroundflipper">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ShopPic1"
android:scaleType="centerCrop"
android:src="@drawable/nestleshop1"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ShopPic2"
android:scaleType="centerCrop"
android:src="@drawable/nestleshop2"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ShopPic3"
android:scaleType="centerCrop"
android:src="@drawable/nestleshop3"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ShopPic4"
android:scaleType="centerCrop"
android:src="@drawable/nestleshop4"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/ShopPic5"
android:scaleType="centerCrop"
android:src="@drawable/nestleshop5"/>
</ViewFlipper>
</FrameLayout>
: 여기
public class SlideshowFragment extends Fragment {
Animation Fade_in,Fade_out;
ViewFlipper viewFlipper;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v=inflater.inflate(R.layout.fragment_slideshow,container,false);
viewFlipper=(ViewFlipper)getView().findViewById(R.id.backgroundflipper);
Fade_in= AnimationUtils.loadAnimation(getActivity(),android.R.anim.fade_in);
Fade_out=AnimationUtils.loadAnimation(getActivity(),android.R.anim.fade_out);
viewFlipper.setInAnimation(Fade_in);
viewFlipper.setInAnimation(Fade_out);
viewFlipper.setAutoStart(true);
viewFlipper.setFlipInterval(5000);
viewFlipper.startFlipping();
return v;
}
}
및 는 조각 XML 코드 작업.
UPDATE : 내 활동 XML :
이 코드viewFlipper=(ViewFlipper)getView().findViewById(R.id.backgroundflipper);
사용이 코드의 장소에서
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main_page"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="ברוך הבא"
android:layout_width="93dp"
android:layout_height="35dp"
android:layout_x="75dp"
android:layout_y="15dp"
android:id="@+id/TextView10" />
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="33dp"
android:layout_x="10dp"
android:layout_y="15dp"
android:id="@+id/ConnectTv"
android:textStyle="bold"
/>
<TextView
android:text="TextView"
android:layout_width="82dp"
android:layout_height="31dp"
android:layout_x="30dp"
android:layout_y="15dp"
android:id="@+id/textView2"></TextView>
<fragment
class="com.example.nir.nestleapp.SlideshowFragment"
android:id="@+id/SlideshowFrag"
android:layout_width="match_parent"
android:layout_height="206dp"
android:layout_y="55dp"
tools:layout="@layout/fragment_maps"
android:layout_x="-4dp">
</fragment>
<Button
android:text="נווט"
android:layout_width="match_parent"
android:layout_height="62dp"
android:layout_x="0dp"
android:layout_y="452dp"
android:id="@+id/Waze" />
<fragment
class="layout.MapsFragment"
android:id="@+id/LowerFrag"
android:layout_width="386dp"
android:layout_height="193dp"
android:layout_y="262dp"
tools:layout="@layout/fragment_maps"
android:layout_x="-4dp">
</fragment>
</AbsoluteLayout>
내 활동 xml? \ –
내 업데이트를보세요 –