gpt4 book ai didi

android - 二进制 XML 文件行 #2 : Error inflating class android. support.constraint.Drawlayout

转载 作者:行者123 更新时间:2023-11-29 18:28:54 25 4
gpt4 key购买 nike

您好,在下面的代码中,我遇到了以下 logcat 错误的问题。

我创建了一个包含左侧抽屉导航的应用程序。当我们从抽屉中单击“帮助”菜单时,它显示以下错误并使应用程序崩溃。崩溃时我收到以下错误。

谁能帮帮我

日志:

 Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.constraint.Drawlayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.constraint.Drawlayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.constraint.Drawlayout" on path: DexPathList[[zip file "/data/app/com.example

HelpActivity.java:

public class HelpActivity extends AppCompatActivity {



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help);
Mint.initAndStartSession(this.getApplication(), ConstantUtils.SPLUNK_MINK_KEY);

DrawerLayout txtSendMail;
DrawerLayout txtCall;
DrawerLayout txtEmailFeedback;
DrawerLayout txtWebsite;

txtSendMail=(DrawerLayout)findViewById(R.id.txt_send_mail);
txtCall=(DrawerLayout)findViewById(R.id.txt_call);
txtEmailFeedback=(DrawerLayout)findViewById(R.id.txt_email_feedback);
txtWebsite=(DrawerLayout)findViewById(R.id.txt_website);


txtSendMail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String toEmailAddress = "customercare@havells.com";
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ toEmailAddress });
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
}
});
txtEmailFeedback.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String toEmailAddress = "customercare@havells.com";
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ toEmailAddress });
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
}
});
txtCall.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String phoneNumnber = "tel:1800103131";
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse(phoneNumnber));
startActivity(callIntent);
}
});
txtWebsite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Uri uri = Uri.parse("http://smart.havells.com");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
});



}




public void BackToGeyser(View view) {

final ImageView viewToAnimate = (ImageView) findViewById(R.id.back_arrow_to_geyser_id);

Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
viewToAnimate.startAnimation(in);
viewToAnimate.setVisibility(View.VISIBLE);

onBackPressed();


}

}

Activity 帮助:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.Drawlayout 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"
android:background="@drawable/chipmonk_background">

<RelativeLayout
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:layout_gravity="center_vertical"
android:background="@color/color_toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<RelativeLayout
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_marginStart="10dp"
android:onClick="BackToGeyser">

<ImageView
android:id="@+id/back_arrow_to_geyser_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginStart="2dp"
android:background="@drawable/ic_arrow_back"
android:onClick="BackToGeyser" />
</RelativeLayout>
<!--
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="25sp"
android:layout_marginTop="2sp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/menu"/>
</RelativeLayout>
-->
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/help"
android:textColor="@color/white"
android:textSize="@dimen/heading_font_size" />

</RelativeLayout>


</RelativeLayout>

<android.support.constraint.Guideline
android:id="@+id/guideline20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.75" />

<android.support.constraint.Guideline
android:id="@+id/guideline21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />

<android.support.constraint.Guideline
android:id="@+id/guideline22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.35" />

<android.support.constraint.Guideline
android:id="@+id/guideline23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.12" />

<android.support.constraint.Guideline
android:id="@+id/guideline24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.88" />

<TextView
android:id="@+id/textView33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/roboto_medium"
android:text="24/7 Customer Support"
android:textColor="@android:color/black"
app:layout_constraintStart_toStartOf="@+id/guideline23"
app:layout_constraintTop_toTopOf="@+id/guideline22" />

<android.support.constraint.ConstraintLayout
android:id="@+id/txt_send_mail"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="24dp"
android:layout_marginTop="8dp"
android:background="@drawable/login_button_background"
android:elevation="4dp"
app:layout_constraintBottom_toTopOf="@+id/guideline21"
app:layout_constraintDimensionRatio="w,1.5:1"
app:layout_constraintEnd_toStartOf="@+id/txt_call"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView33">

<ImageView
android:id="@+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="@+id/guideline25"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_message" />

<android.support.constraint.Guideline
android:id="@+id/guideline25"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />

<TextView
android:id="@+id/textView34"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="send an email"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="@android:color/white"
android:textSize="10sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline25" />
</android.support.constraint.ConstraintLayout>

<android.support.constraint.ConstraintLayout
android:id="@+id/txt_call"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="8dp"
android:background="@drawable/login_button_background"
android:elevation="4dp"
app:layout_constraintBottom_toTopOf="@+id/guideline21"
app:layout_constraintDimensionRatio="w,1.5:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/txt_send_mail"
app:layout_constraintTop_toBottomOf="@+id/textView33"
app:layout_constraintVertical_bias="0.0">

<ImageView
android:id="@+id/imageView10"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="@+id/guideline27"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_phone" />

<android.support.constraint.Guideline
android:id="@+id/guideline27"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />

<TextView
android:id="@+id/textView36"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="call us"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="@android:color/white"
android:textSize="10sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline27" />
</android.support.constraint.ConstraintLayout>

<TextView
android:id="@+id/textView38"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:fontFamily="@font/roboto_medium"
android:text="Send feedback on Geyser App "
android:textColor="@android:color/black"
app:layout_constraintStart_toStartOf="@+id/guideline23"
app:layout_constraintTop_toTopOf="@+id/guideline21" />

<android.support.constraint.ConstraintLayout
android:id="@+id/txt_email_feedback"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="8dp"
android:background="@drawable/login_button_background"
android:elevation="4dp"
app:layout_constraintBottom_toTopOf="@+id/guideline20"
app:layout_constraintDimensionRatio="h,1.5:1"
app:layout_constraintEnd_toEndOf="@+id/txt_send_mail"
app:layout_constraintStart_toStartOf="@+id/txt_send_mail"
app:layout_constraintTop_toBottomOf="@+id/textView38">

<ImageView
android:id="@+id/imageView11"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="@+id/guideline1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_message" />

<android.support.constraint.Guideline
android:id="@+id/guideline1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="email us"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="@android:color/white"
android:textSize="10sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline1" />
</android.support.constraint.ConstraintLayout>

<TextView
android:id="@+id/textView39"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/roboto_medium"
android:text="For any further details"
android:textColor="@android:color/black"
app:layout_constraintStart_toStartOf="@+id/guideline23"
app:layout_constraintTop_toTopOf="@+id/guideline20" />

<android.support.constraint.ConstraintLayout
android:id="@+id/txt_website"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:background="@drawable/login_button_background"
android:elevation="4dp"
app:layout_constraintDimensionRatio="1.5:1"
app:layout_constraintEnd_toEndOf="@+id/txt_send_mail"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/txt_send_mail"
app:layout_constraintTop_toBottomOf="@+id/textView39">

<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="16dp"
app:layout_constraintBottom_toTopOf="@+id/guideline2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_web" />

<android.support.constraint.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.55" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="havells india ltd"
android:textAlignment="center"
android:textAllCaps="true"
android:textColor="@android:color/white"
android:textSize="10sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2" />
</android.support.constraint.ConstraintLayout>

</android.support.constraint.Drawlayout>

最佳答案

输入错误,进行如下修改

 ConstraintLayout txtSendMail;
ConstraintLayout txtCall;
ConstraintLayouttxtEmailFeedback;
ConstraintLayout txtWebsite;

txtSendMail=(ConstraintLayout)findViewById(R.id.txt_send_mail);
txtCall=(ConstraintLayout)findViewById(R.id.txt_call);
txtEmailFeedback=(ConstraintLayout)findViewById(R.id.txt_email_feedback);
txtWebsite=(ConstraintLayout)findViewById(R.id.txt_website);

关于android - 二进制 XML 文件行 #2 : Error inflating class android. support.constraint.Drawlayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57456428/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com