ActionBarSherlockを使用するアプリを開発しています。このアプリはSDKv15(ICS)で実行すると正常に動作しますが、SDK v8(Froyo)ではクラッシュします。
これが私が得ているエラーです:
E/AndroidRuntime( 489): FATAL EXCEPTION: main
E/AndroidRuntime( 489): android.view.InflateException: Binary XML file line #10: Error inflating class <unknown>
E/AndroidRuntime( 489): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
E/AndroidRuntime( 489): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
E/AndroidRuntime( 489): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
E/AndroidRuntime( 489): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
E/AndroidRuntime( 489): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
E/AndroidRuntime( 489): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
E/AndroidRuntime( 489): at com.finerrecliner.HeadlineAdapter.getView(HeadlineAdapter.java:44)
E/AndroidRuntime( 489): at android.widget.AbsListView.obtainView(AbsListView.java:1315)
E/AndroidRuntime( 489): at android.widget.ListView.makeAndAddView(ListView.java:1727)
E/AndroidRuntime( 489): at android.widget.ListView.fillDown(ListView.java:652)
E/AndroidRuntime( 489): at android.widget.ListView.fillFromTop(ListView.java:709)
E/AndroidRuntime( 489): at android.widget.ListView.layoutChildren(ListView.java:1566)
E/AndroidRuntime( 489): at android.widget.AbsListView.onLayout(AbsListView.java:1147)
E/AndroidRuntime( 489): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 489): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime( 489): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 489): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime( 489): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 489): at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1388)
E/AndroidRuntime( 489): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 489): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime( 489): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 489): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
E/AndroidRuntime( 489): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
E/AndroidRuntime( 489): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
E/AndroidRuntime( 489): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 489): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime( 489): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 489): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime( 489): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 489): at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
E/AndroidRuntime( 489): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
E/AndroidRuntime( 489): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 489): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 489): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 489): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 489): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 489): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 489): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 489): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 489): Caused by: java.lang.reflect.InvocationTargetException
E/AndroidRuntime( 489): at android.widget.TextView.<init>(TextView.java:321)
E/AndroidRuntime( 489): at java.lang.reflect.Constructor.constructNative(Native Method)
E/AndroidRuntime( 489): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
E/AndroidRuntime( 489): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
E/AndroidRuntime( 489): ... 39 more
E/AndroidRuntime( 489): Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x2
E/AndroidRuntime( 489): at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
E/AndroidRuntime( 489): at android.view.View.<init>(View.java:1891)
E/AndroidRuntime( 489): at android.widget.TextView.<init>(TextView.java:327)
E/AndroidRuntime( 489): ... 43 more
問題の関連XMLは次のとおりです(10行目は最初のTextViewが宣言されたときです):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16dp"
android:textColor="#000000"
android:gravity="center_vertical"
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/source_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="10dp"
android:textColor="#666666"
android:gravity="center_vertical"
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
/>
</LinearLayout>
そして、これが関連する私のHeadlineAdapter.javaコードです(44行目はコメント付きで示されています):
class HeadlineAdapter extends ArrayAdapter<SyndEntryEnhanced> {
private int mLayoutResourceID;
private Context mContext;
private class HeadlineHolder {
TextView title;
TextView source_date;
}
public HeadlineAdapter(Context context, int textViewResourceId, ArrayList<SyndEntryEnhanced> list) {
super(context, textViewResourceId, list);
this.mContext = context;
this.mLayoutResourceID = textViewResourceId;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
HeadlineHolder holder = null;
if (row == null) {
LayoutInflater infl = (LayoutInflater)((SherlockFragmentActivity)mContext).getLayoutInflater();
row = infl.inflate(mLayoutResourceID, parent, false); // LINE 44
holder = new HeadlineHolder();
holder.title = (TextView)row.findViewById(R.id.title);
holder.source_date = (TextView)row.findViewById(R.id.source_date);
row.setTag(holder);
} else {
holder = (HeadlineHolder)row.getTag();
}
SyndEntry entry = super.getItem(position).getEntry();
String title = super.getItem(position).getFeedTitle().trim();
Date date = entry.getPublishedDate();
SimpleDateFormat formatter = new SimpleDateFormat("MMM d", Locale.US);
holder.title.setText(StringEscapeUtils.unescapeHtml(entry.getTitle()));
if (date == null) {
holder.source_date.setText(title);
} else {
holder.source_date.setText(title + " - " + formatter.format(date));
}
return row;
}
}
何か案は?