0

이 앱을 이미 내 앱에서 사용 했으므로 정상적으로 작동합니다. 지금 정확히 똑같은 일을하고 있지만 다음과 같은 오류 메시지가 나타납니다. android.view.View 클래스를 확장하는 중 오류가 발생했습니다. 이전 화면과 동일한 기본 XML 레이아웃을 사용하고 있습니다. 그것에는 2 개의 파편이 있습니다. 해당 사용자가 로그인했음을 알리는 맨 위 하나와 아래에 새 단편 (양식)이 있습니다. 그러나 아래의 문제가 문제인 것처럼 보입니다. 당신은 정말이 일을해야하는 경우 모르지만 여기가이 조각에서 레이아웃을 부 풀릴 때 오류가 발생합니다.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:id="@+id/container_for_loggedin_textview" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:padding="5dp" 
      tools:context="com.bignerdranch.android.personaltrainer.LoggedInFragment"> 

    <TextView 
     android:id="@+id/logged_in_text_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:text="You are logged in" 
     android:textAlignment="center" 
     android:textSize="18sp" 
     android:textStyle="bold|italic"/> 

</FrameLayout> 
다음

조각 위치가 나는 문제에 봉착입니다 : 여기

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.bignerdranch.android.personaltrainer.CustomerListActivity"> 

    <LinearLayout 
     android:layout_width="304dp" 
     android:layout_height="wrap_content" 
     android:id="@+id/logged_in_fragment_container" 
     android:orientation="horizontal" 
     android:layout_marginLeft="8dp" 
     app:layout_constraintLeft_toLeftOf="parent" 
     android:layout_marginRight="8dp" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     android:layout_marginTop="8dp" 
     tools:layout_height="18dp" 
     android:layout_marginBottom="8dp" 
     app:layout_constraintBottom_toTopOf="@+id/list_fragment_container" 
     android:layout_marginStart="8dp" 
     android:layout_marginEnd="8dp"> 

    </LinearLayout> 

    <android.support.constraint.ConstraintLayout 
     android:id="@+id/list_fragment_container" 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     android:layout_marginBottom="8dp" 
     android:layout_marginLeft="8dp" 
     android:layout_marginRight="8dp" 
     android:layout_marginTop="34dp" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintHorizontal_bias="0.0" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     android:layout_marginStart="8dp" 
     android:layout_marginEnd="8dp"> 

    </android.support.constraint.ConstraintLayout> 

</android.support.constraint.ConstraintLayout> 

상단의 fragment입니다 : 여기 내 기본 레이아웃입니다 내가하려고 할 때 그것을 팽창하기 :

: 여기
<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <TextView 
     android:id="@+id/textView_new_customer_title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:layout_marginTop="16dp" 
     android:text="@string/new_customer_title" 
     android:textSize="24sp" 
     android:textStyle="bold" 
     android:typeface="serif" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     android:layout_marginStart="16dp"/> 

    <ImageView 
     android:id="@+id/new_customer_pic" 
     android:layout_width="84dp" 
     android:layout_height="82dp" 
     android:layout_marginLeft="16dp" 
     android:layout_marginStart="16dp" 
     android:layout_marginTop="60dp" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     app:srcCompat="@mipmap/ic_launcher"/> 

    <EditText 
     android:id="@+id/tv_first_name" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginEnd="16dp" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp" 
     android:layout_marginStart="16dp" 
     android:layout_marginTop="152dp" 
     android:ems="10" 
     android:hint="First Name" 
     android:inputType="textPersonName" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent"/> 

    <EditText 
     android:id="@+id/tv_last_name" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp" 
     android:layout_marginTop="5dp" 
     android:ems="10" 
     android:hint="Last Name" 
     android:inputType="textPersonName" 
     app:layout_constraintHorizontal_bias="0.0" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/tv_first_name" 
     android:layout_marginStart="16dp" 
     android:layout_marginEnd="16dp"/> 

    <EditText 
     android:id="@+id/tv_city" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:ems="10" 
     android:hint="City" 
     android:inputType="textPersonName" 
     app:layout_constraintLeft_toLeftOf="parent" 
     android:layout_marginStart="16dp" 
     android:layout_marginTop="5dp" 
     app:layout_constraintTop_toBottomOf="@+id/tv_address"/> 

    <Spinner 
     android:id="@+id/spinner_state" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="8dp" 
     android:layout_marginEnd="8dp" 
     android:layout_marginLeft="8dp" 
     android:layout_marginRight="8dp" 
     android:layout_marginStart="8dp" 
     android:layout_marginTop="8dp" 
     android:background="@color/colorPrimary" 
     android:entries="@array/states" 
     app:layout_constraintBottom_toBottomOf="@+id/tv_city" 
     app:layout_constraintHorizontal_bias="0.433" 
     app:layout_constraintLeft_toRightOf="@+id/tv_city" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/tv_last_name" 
     app:layout_constraintVertical_bias="0.913"/> 

    <EditText 
     android:id="@+id/tv_zip" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:layout_marginTop="5dp" 
     android:ems="10" 
     android:hint="ZipCode" 
     android:inputType="textPersonName" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/tv_city" 
     android:layout_marginStart="16dp"/> 

    <View 
     android:layout_width="0dp" 
     android:layout_height="2dp" 
     android:background="@color/colorPrimaryDark" 
     android:backgroundTint="@drawable/divider" 
     android:layout_marginLeft="8dp" 
     app:layout_constraintLeft_toLeftOf="parent" 
     android:layout_marginRight="8dp" 
     app:layout_constraintRight_toRightOf="parent" 
     android:id="@+id/view" 
     android:layout_marginStart="8dp" 
     android:layout_marginEnd="8dp" 
     app:layout_constraintHorizontal_bias="1.0" 
     app:layout_constraintTop_toBottomOf="@+id/tv_zip"/> 

    <Button 
     android:id="@+id/cancel_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/cancel_button" 
     android:layout_marginTop="8dp" 
     app:layout_constraintTop_toBottomOf="@+id/view" 
     android:layout_marginLeft="8dp" 
     app:layout_constraintLeft_toLeftOf="parent" 
     android:layout_marginStart="8dp"/> 

    <Button 
     android:id="@+id/add_customer_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/add_button" 
     android:layout_marginRight="8dp" 
     app:layout_constraintRight_toRightOf="parent" 
     android:layout_marginTop="8dp" 
     app:layout_constraintTop_toBottomOf="@+id/view" 
     android:layout_marginStart="64dp" 
     android:layout_marginEnd="8dp" 
     app:layout_constraintLeft_toRightOf="@+id/camera_button"/> 


    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/camera_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/ic_camera_black_24dp" 
     app:backgroundTint="@color/colorPrimaryDark" 
     app:elevation="6dp" 
     app:fabSize="auto" 
     app:rippleColor="?android:attr/colorBackground" 
     android:layout_marginTop="10dp" 
     app:layout_constraintTop_toBottomOf="@+id/view" 
     android:layout_marginStart="64dp" 
     app:layout_constraintLeft_toRightOf="@+id/cancel_button" 
     android:layout_marginLeft="64dp"/> 

    <Button 
     android:id="@+id/billing_info_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/billing_info_button" 
     android:layout_marginRight="16dp" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     android:layout_marginTop="60dp" 
     android:layout_marginEnd="16dp"/> 

    <EditText 
     android:id="@+id/tv_address" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp" 
     android:layout_marginTop="4dp" 
     android:ems="10" 
     android:hint="Street Address" 
     android:inputType="textPersonName" 
     app:layout_constraintHorizontal_bias="0.503" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/tv_last_name" 
     android:layout_marginStart="16dp" 
     android:layout_marginEnd="16dp"/> 

</android.support.constraint.ConstraintLayout> 

내가 조각 관리자를 사용하여 기본 활동입니다 (210)

그리고 여기에 오류를 던지고 조각입니다 :

package com.bignerdranch.android.personaltrainer; 

import android.os.Bundle; 
import android.support.design.widget.FloatingActionButton; 
import android.support.v4.app.Fragment; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.Button; 
import android.widget.ImageView; 
import android.widget.Spinner; 
import android.widget.TextView; 

import com.bignerdranch.android.personaltrainer.model.Customer; 

/** 
* Created by patricgekoski on 9/3/17. 
*/ 

public class NewCustomerFragment extends Fragment { 

    private Customer mCustomer; 
    private Button mBillingInfoButton; 
    private Button mCancelButton; 
    private Button mAddButton; 
    private FloatingActionButton mCameraButton; 
    private ImageView mCustomerPic; 
    private TextView mFirstName; 
    private TextView mLastName; 
    private TextView mAddress; 
    private TextView mCity; 
    private Spinner mState; 
    private TextView mZip; 

    public NewCustomerFragment(){ 
     // empty constructor 
    } 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup parent, 
          Bundle savedInstanceState){ 

// !!!!!!! 이 다음 줄이 오류를 돌파하고 있습니다 !!!!!!!!!!!

 View view = inflater.inflate(R.layout.fragment_new_customer, parent, false); 


     mBillingInfoButton.findViewById(R.id.billing_info_button); 
     mCancelButton.findViewById(R.id.cancel_button); 
     mAddButton.findViewById(R.id.add_customer_button); 
     mCameraButton.findViewById(R.id.camera_button); 
     mCustomerPic.findViewById(R.id.new_customer_pic); 
     mFirstName.findViewById(R.id.tv_first_name); 
     mLastName.findViewById(R.id.tv_last_name); 
     mAddress.findViewById(R.id.tv_address); 
     mCity.findViewById(R.id.tv_city); 
     mState.findViewById(R.id.spinner_state); 
     mZip.findViewById(R.id.tv_zip); 

     return view; 

    } 
} 

은 마지막으로 여기 내 스택 추적입니다 : 나는 그것을 알아 낸 것이

09-03 10:25:50.996 29649-29649/com.bignerdranch.android.personaltrainer E/AndroidRuntime: FATAL EXCEPTION: main 
                          Process: com.bignerdranch.android.personaltrainer, PID: 29649 
                          java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bignerdranch.android.personaltrainer/com.bignerdranch.android.personaltrainer.NewCustomerActivity}: android.view.InflateException: Binary XML file line #112: Binary XML file line #112: Error inflating class android.view.View 
                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) 
                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                           at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                           at android.os.Handler.dispatchMessage(Handler.java:102) 
                           at android.os.Looper.loop(Looper.java:148) 
                           at android.app.ActivityThread.main(ActivityThread.java:5417) 
                           at java.lang.reflect.Method.invoke(Native Method) 
                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                          Caused by: android.view.InflateException: Binary XML file line #112: Binary XML file line #112: Error inflating class android.view.View 
                           at android.view.LayoutInflater.inflate(LayoutInflater.java:539) 
                           at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
                           at com.bignerdranch.android.personaltrainer.NewCustomerFragment.onCreateView(NewCustomerFragment.java:43) 
                           at android.support.v4.app.Fragment.performCreateView(Fragment.java:2239) 
                           at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1332) 
                           at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1574) 
                           at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1641) 
                           at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:794) 
                           at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415) 
                           at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2200) 
                           at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2153) 
                           at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2063) 
                           at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388) 
                           at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:554) 
                           at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177) 
                           at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237) 
                           at android.app.Activity.performStart(Activity.java:6253) 
                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379) 
                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  
                           at android.app.ActivityThread.-wrap11(ActivityThread.java)  
                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  
                           at android.os.Handler.dispatchMessage(Handler.java:102)  
                           at android.os.Looper.loop(Looper.java:148)  
                           at android.app.ActivityThread.main(ActivityThread.java:5417)  
                           at java.lang.reflect.Method.invoke(Native Method)  
                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  
                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  
                          Caused by: android.view.InflateException: Binary XML file line #112: Error inflating class android.view.View 
                           at android.view.LayoutInflater.createView(LayoutInflater.java:645) 
                           at android.view.LayoutInflater.onCreateView(LayoutInflater.java:677) 
                           at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:68) 
                           at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694) 
                           at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762) 
                           at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
                           at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
                           at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
                           at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
                           at android.view.LayoutInflater.inflate(LayoutInflater.java:423)  
                           at com.bignerdranch.android.personaltrainer.NewCustomerFragment.onCreateView(NewCustomerFragment.java:43)  
                           at android.support.v4.app.Fragment.performCreateView(Fragment.java:2239)  
                           at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1332)  
                           at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1574)  
                           at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1641)  
                           at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:794)  
                           at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415)  
                           at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2200)  
                           at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2153)  
                           at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2063)  
                           at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)  
                           at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:554)  
                           at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177)  
                           at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)  
                           at android.app.Activity.performStart(Activity.java:6253)  
                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)  
                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  
                           at android.app.ActivityThread.-wrap11(ActivityThread.java)  
                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  
                           at android.os.Handler.dispatchMessage(Handler.java:102)  
                           at android.os.Looper.loop(Looper.java:148)  
                           at android.app.ActivityThread.main(ActivityThread.java:5417)  
                           at java.lang.reflect.Method.invoke(Native Method)  
                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  
                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  

의 적어도 일부가 사전

답변

0

에 감사드립니다. 이것은 매우 미묘한 실수입니다. 내 레이아웃에서 "backgroundTint"속성을 사용하려고했지만 최소 API 인 19보다 높은 레벨에서 소개되었습니다.

0

inflate부터 findView까지 해당 부분의 모든 코드를 주석 처리 해보세요. 문제가 지속되면 스택 추적에서 제안한대로 NumbersActivity에서 문제가 발생할 수 있으므로 자세한 정보를 보려면 NumbersFragment를 호출하는 부분을 주석 처리하십시오. 희망은 당신을 해결책으로 인도합니다.

관련 문제