我正在使用NavigationBar
所以在其中一个片段中,我在实现点击卡片视图时遇到错误。虽然点击工作正在测试它与吐司,但使用意图到达另一个活动是不起作用。
java.lang.RuntimeException: Unable to start activity ComponentInfo{minor.da.com.donationapp/minor.da.com.donationapp.SecondPage}: android.view.InflateException: Binary XML file line #6: Binary XML file line #6: Error inflating class <unknown>
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 #6: Binary XML file line #6: Error inflating class <unknown>
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
at android.app.Activity.setContentView(Activity.java:2172)
at minor.da.com.donationapp.SecondPage.onCreate(SecondPage.java:15)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="241dp"
android:layout_height="202dp"
android:textAppearance="@android:color/darker_gray"
android:text="Hello link to your card view"
android:id="@+id/textView2"
android:gravity="center|center_horizontal|fill"
android:enabled="true"
android:editable="false"
android:textAlignment="@android:integer/config_shortAnimTime"
android:textColor="#f4086172"
android:textStyle="bold|italic" />
</LinearLayout>
ADAPTER CLASS CODE
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Collections;
import java.util.List;
public class vizAdapter extends RecyclerView.Adapter<vizAdapter.Myviewholder> {
private LayoutInflater inflater;
private Context context;
List<information> data= Collections.emptyList();
public vizAdapter(Context context, List<information> data){
inflater = LayoutInflater.from(context);
this.context=context;
this.data=data;
}
@Override
public Myviewholder onCreateViewHolder(ViewGroup parent, int viewType) {
View view=inflater.inflate(R.layout.custom_row, parent, false);
Myviewholder holder=new Myviewholder(view);
return holder;
}
@Override
public void onBindViewHolder(Myviewholder holder, int position) {
information current=data.get(position);
holder.text.setText(current.title);
holder.icon.setImageResource(current.iconId);
}
@Override
public int getItemCount() {
return data.size();
}
class Myviewholder extends RecyclerView.ViewHolder{
TextView text;
ImageView icon;
public Myviewholder( View itemView) {
super(itemView);
text= (TextView) itemView.findViewById(R.id.listtext);
icon= (ImageView) itemView.findViewById(R.id.listicon);
getView(itemView);
}
}
public View getView(View v){
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(context,SecondPage.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
context.startActivity(i);
Toast.makeText(context,"hello successful",Toast.LENGTH_SHORT);
}
});
return v;
}
}
答案 0 :(得分:0)
您应该删除android:textAlignment="@android:integer/config_shortAnimTime"
TextView
config_shortAnimTime
是动画的持续时间
要查找android:textAlignment
允许的属性,请参阅此处
http://developer.android.com/intl/es/reference/android/view/View.html#attr_android:textAlignment
希望这能帮到你