我的XML文件是::
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/abcTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/text_nor"
android:textSize="@dimen/index_tv_txt" />
此部分的代码是:
LayoutInflater inflater = getLayoutInflater();
//LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View viLin = inflater.inflate(R.layout.abcdeitem, null);
Log.d("Check ---1", indexListSize+"---"+i);
final TextView tv = (TextView) viLin.findViewById(R.id.abcTv);
Log.d("Check ---1", indexListSize+"---"+i);
tv.setText(tmpLetter);
tv.setGravity(Gravity.CENTER);
if(tempVal.trim().equalsIgnoreCase(tmpLetter.trim()))
{
Log.d("Check ---2", indexListSize+"---"+i);
tv.setTextColor(Color.rgb(90, 17, 17));
tv.setBackgroundResource(R.drawable.text_active);
}
else
{
Log.d("Check ---3", indexListSize+"---"+i);
tv.setTextColor(Color.rgb(161, 0, 0));
tv.setBackgroundResource(R.drawable.text_nor);
}
viLin.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
mySearch.setText("");
Log.d("LOG", "Click 2");
addCountriesInQ();
tempVal=tv.getText().toString().trim();
int subitemPosition = sections.get(tmpIndexItem[0]);
//ListView listView = (ListView) findViewById(android.R.id.list);
getListView().setSelection(subitemPosition);
updateList();
}
});
Log.d("Check ---4", indexListSize+"---"+i);
sideIndex.addView(viLin);
Log.d("Check ---5", indexListSize+"---"+i);
}
sideIndexHeight = sideIndex.getHeight();
错误日志::
07-07 11:20:31.632: D/Check(15185): **********************************
07-07 11:20:31.680: D/Check 1(15185): 1
07-07 11:20:31.681: D/Check 2(15185): 2
07-07 11:20:31.682: D/Check 3(15185): 3
07-07 11:20:31.732: D/Check 33(15185): 33
07-07 11:20:31.733: D/Check 4(15185): 4
07-07 11:20:31.734: D/Check 5(15185): 5
07-07 11:20:31.734: D/Check 6(15185): 6
07-07 11:20:31.734: D/Check ---(15185): 13---1.0
07-07 11:20:31.737: W/ResourceType(15185): Failure getting entry for 0x7f02005d (t=1 e=93) in package 0 (error -75)
07-07 11:20:31.739: D/AndroidRuntime(15185): Shutting down VM
07-07 11:20:31.739: W/dalvikvm(15185): threadid=1: thread exiting with uncaught exception (group=0x40fae258)
07-07 11:20:31.759: E/AndroidRuntime(15185): FATAL EXCEPTION: main
07-07 11:20:31.759: E/AndroidRuntime(15185): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.infotech.supertron.bnicontactapp/com.infotech.supertron.bnicontactapp.MemberContactActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2077)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.app.ActivityThread.access$600(ActivityThread.java:134)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.os.Handler.dispatchMessage(Handler.java:99)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.os.Looper.loop(Looper.java:154)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.app.ActivityThread.main(ActivityThread.java:4624)
07-07 11:20:31.759: E/AndroidRuntime(15185): at java.lang.reflect.Method.invokeNative(Native Method)
07-07 11:20:31.759: E/AndroidRuntime(15185): at java.lang.reflect.Method.invoke(Method.java:511)
07-07 11:20:31.759: E/AndroidRuntime(15185): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
07-07 11:20:31.759: E/AndroidRuntime(15185): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
07-07 11:20:31.759: E/AndroidRuntime(15185): at dalvik.system.NativeStart.main(Native Method)
07-07 11:20:31.759: E/AndroidRuntime(15185): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.view.LayoutInflater.createView(LayoutInflater.java:608)
07-07 11:20:31.759: E/AndroidRuntime(15185): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:57)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:655)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.view.LayoutInflater.inflate(LayoutInflater.java:468)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
07-07 11:20:31.759: E/AndroidRuntime(15185): at com.infotech.supertron.bnicontactapp.MemberContactActivity.updateList(MemberContactActivity.java:248)
07-07 11:20:31.759: E/AndroidRuntime(15185): at com.infotech.supertron.bnicontactapp.MemberContactActivity.onCreate(MemberContactActivity.java:139)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.app.Activity.performCreate(Activity.java:4479)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2041)
07-07 11:20:31.759: E/AndroidRuntime(15185): ... 11 more
07-07 11:20:31.759: E/AndroidRuntime(15185): Caused by: java.lang.reflect.InvocationTargetException
07-07 11:20:31.759: E/AndroidRuntime(15185): at java.lang.reflect.Constructor.constructNative(Native Method)
07-07 11:20:31.759: E/AndroidRuntime(15185): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.view.LayoutInflater.createView(LayoutInflater.java:588)
07-07 11:20:31.759: E/AndroidRuntime(15185): ... 22 more
07-07 11:20:31.759: E/AndroidRuntime(15185): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02005d a=-1 r=0x7f02005d}
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.content.res.Resources.loadDrawable(Resources.java:1932)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.content.res.TypedArray.getDrawable(TypedArray.java:608)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.view.View.<init>(View.java:2791)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.widget.TextView.<init>(TextView.java:454)
07-07 11:20:31.759: E/AndroidRuntime(15185): at android.widget.TextView.<init>(TextView.java:447)
07-07 11:20:31.759: E/AndroidRuntime(15185): ... 25 more
07-07 11:20:33.466: I/Process(15185): Sending signal. PID: 15185 SIG: 9
它在布局时给出错误。
答案 0 :(得分:2)
引起:android.content.res.Resources $ NotFoundException:Resource 不是Drawable(颜色或路径):TypedValue {t = 0x1 / d = 0x7f02005d a = -1 R = 0x7f02005d}
Andorid无法找到资源@drawable/text_nor
。检查相应的可绘制文件夹中是否有指定的drawable。
由op
评论我已将@ drawable / text_nor放置到drawable-hdpi文件夹,并且我的手机支持为drawable-large-mdpi
来自您的评论
它是背景颜色
此外,如果text_nor是一种颜色,则在colors.xml中定义颜色代码,并将其引用为@color/name