我是android新手,在logcat中运行我的应用程序时遇到了很多错误。

11-26 16:21:42.787: E/AndroidRuntime(1103): FATAL EXCEPTION: main
11-26 16:21:42.787: E/AndroidRuntime(1103): java.lang.RuntimeException: Unable to    start activity ComponentInfo{com.example.trove.sms/com.example.trove.sms.MainMenu}: android.view.InflateException: Binary XML file line #30: Error inflating class com.android.internal.widget.ActionBarView
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.os.Looper.loop(Looper.java:137)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.app.ActivityThread.main(ActivityThread.java:4745)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at java.lang.reflect.Method.invokeNative(Native Method)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at java.lang.reflect.Method.invoke(Method.java:511)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at dalvik.system.NativeStart.main(Native Method)
11-26 16:21:42.787: E/AndroidRuntime(1103): Caused by: android.view.InflateException: Binary XML file line #30: Error inflating class com.android.internal.widget.ActionBarView
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.createView(LayoutInflater.java:613)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at   android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2784)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2844)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:252)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.app.Activity.setContentView(Activity.java:1867)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at com.example.trove.sms.MainMenu.onCreate(MainMenu.java:35)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.app.Activity.performCreate(Activity.java:5008)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
11-26 16:21:42.787: E/AndroidRuntime(1103):     ... 11 more
11-26 16:21:42.787: E/AndroidRuntime(1103): Caused by: java.lang.reflect.InvocationTargetException
11-26 16:21:42.787: E/AndroidRuntime(1103):     at java.lang.reflect.Constructor.constructNative(Native Method)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.createView(LayoutInflater.java:587)
11-26 16:21:42.787: E/AndroidRuntime(1103):     ... 25 more
11-26 16:21:42.787: E/AndroidRuntime(1103): Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.widget.TextView
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.createView(LayoutInflater.java:613)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at com.android.internal.widget.ActionBarView.initTitle(ActionBarView.java:763)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at com.android.internal.widget.ActionBarView.setDisplayOptions(ActionBarView.java:596)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at com.android.internal.widget.ActionBarView.<init>(ActionBarView.java:238)
11-26 16:21:42.787: E/AndroidRuntime(1103):     ... 28 more
11-26 16:21:42.787: E/AndroidRuntime(1103): Caused by: java.lang.reflect.InvocationTargetException
11-26 16:21:42.787: E/AndroidRuntime(1103):     at java.lang.reflect.Constructor.constructNative(Native Method)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.view.LayoutInflater.createView(LayoutInflater.java:587)
11-26 16:21:42.787: E/AndroidRuntime(1103):     ... 38 more
11-26 16:21:42.787: E/AndroidRuntime(1103): Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.content.res.TypedArray.getColor(TypedArray.java:326)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.widget.TextView.<init>(TextView.java:499)
11-26 16:21:42.787: E/AndroidRuntime(1103):     at android.widget.TextView.<init>(TextView.java:442)
11-26 16:21:42.787: E/AndroidRuntime(1103):     ... 41 more

我没有使用ActionBar,因此无法找出问题所在。
public void onCreate(Bundle savedInstanceState)
{
 super.onCreate(savedInstanceState);
 setContentView(R.layout.mainmenu)//line 35;
 gridView = (GridView) findViewById(R.id.gridView1);
 gridView.setAdapter(new iconadapter(this)); ....
 }

我的主菜单XML文件是
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/gridView1"
android:numColumns="auto_fit"
android:gravity="center"
android:columnWidth="100dp"
android:stretchMode="columnWidth"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!--android:background="#000000"-->
</GridView>

我在网上搜索了几个小时,但找不到任何解决办法。
任何帮助都将不胜感激。
这是我的图标识别课,是的,我在开始时用了小写字母,这是问题吗?
public class iconadapter extends BaseAdapter {
private Context context;
private final String icon_text[]={"CREATE MESSAGE","LIST  MESSAGES","BACKUP/RESTORE","SETTINGS","ABOUT"};

public iconadapter(Context context)
{
    this.context = context;

}

public View getView(int position, View convertView, ViewGroup parent) {

    LayoutInflater inflater = (LayoutInflater) context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View gridView;

    if (convertView == null)
    {

        gridView = new View(context);

        // get layout from mobile.xml
        gridView = inflater.inflate(R.layout.icons, null);

        // set value into textview
        TextView textView = (TextView) gridView
                .findViewById(R.id.grid_item_label);
        textView.setText(icon_text[position]);

        // set image based on selected text
        ImageView imageView = (ImageView) gridView
                .findViewById(R.id.grid_item_image);

        String icon_label = icon_text[position];

        if (icon_label.equals("CREATE MESSAGE")) {
            imageView.setImageResource(R.drawable.create);
        } else if (icon_label.equals("LIST MESSAGES")) {
            imageView.setImageResource(R.drawable.mesage);
        } else if (icon_label.equals("BACKUP/RESTORE")) {
            imageView.setImageResource(R.drawable.backup1);
        } else if (icon_label.equals("SETTINGS")){
            imageView.setImageResource(R.drawable.settings);
        }
        else imageView.setImageResource(R.drawable.about);

    } else {
        gridView = (View) convertView;
    }

    return gridView;
}

public int getCount() {
    // TODO Auto-generated method stub
    return icon_text.length;
}

public Object getItem(int arg0) {
    // TODO Auto-generated method stub
    return null;
}

public long getItemId(int arg0) {
    // TODO Auto-generated method stub
    return 0;
}
 }

在这里我只是设置我的应用程序图标,这只是不同的选项,意味着标签对应的图像。
我正在膨胀的iconadapter的xml文件是
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:orientation="vertical"
android:background="#000000">

<ImageView
    android:id="@+id/grid_item_image"
    android:layout_width="70sp"
    android:layout_height="70sp"
    android:src="@drawable/create"
     android:contentDescription="@string/desc">
</ImageView>

<TextView
    android:id="@+id/grid_item_label"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    android:text="@+id/label"
    android:layout_marginTop="5dp" >
    <!--android:textColor="#ffffff"  -->
</TextView>

</LinearLayout>

最佳答案

什么是Iconadapter(这个)?
你确定你创建了一个开头有小写字母的类?
另外,我们需要知道你在iConadapter做什么。

08-18 04:04