私はこのコードを持っていますが、動作したくありません。
また、Main.javaの76行目では、これがonCreateに含まれています。
setListAdapter(new ImageAndTextAdapter(ctx, R.layout.lchs_item,
items, icons));
imageandtextadapter.java:
public class ImageAndTextAdapter extends ArrayAdapter<String> {
private LayoutInflater mInflater;
private String[] mStrings;
private TypedArray mIcons;
private int mViewResourceId;
public ImageAndTextAdapter(Context ctx, int viewResourceId,
String[] strings, TypedArray icons) {
super(ctx, viewResourceId, strings);
mInflater = (LayoutInflater)ctx.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
mStrings = strings;
mIcons = icons;
mViewResourceId = viewResourceId;
}
@Override
public int getCount() {
return mStrings.length;
}
@Override
public String getItem(int position) {
return mStrings[position];
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView = mInflater.inflate(mViewResourceId, null);
ImageView iv = (ImageView)convertView.findViewById(R.id.item_icon);
iv.setImageDrawable(mIcons.getDrawable(position));
TextView tv = (TextView)convertView.findViewById(R.id.item_text);
tv.setText(mStrings[position]);
return convertView;
}
}
Logcat
`02-16 00:19:36.867: E/InputManager-JNI(379): An exception was thrown by callback 'interceptKeyBeforeQueueing'.
02-16 00:19:36.867: E/AndroidRuntime(27101): FATAL EXCEPTION: main
02-16 00:19:36.867: E/AndroidRuntime(27101): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.twk95.lchs.browser/com.twk95.lchs.browser.Main}: java.lang.ClassCastException: com.android.internal.policy.impl.PhoneLayoutInflater cannot be cast to org.holoeverywhere.LayoutInflater
02-16 00:19:36.867: E/AndroidRuntime(27101): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
02-16 00:19:36.867: E/AndroidRuntime(27101): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2356)
02-16 00:19:36.867: E/AndroidRuntime(27101): at android.app.ActivityThread.access$600(ActivityThread.java:150)
02-16 00:19:36.867: E/AndroidRuntime(27101): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
02-16 00:19:36.867: E/AndroidRuntime(27101): at android.os.Handler.dispatchMessage(Handler.java:99)
02-16 00:19:36.867: E/AndroidRuntime(27101): at android.os.Looper.loop(Looper.java:137)
02-16 00:19:36.867: E/AndroidRuntime(27101): at android.app.ActivityThread.main(ActivityThread.java:5195)
02-16 00:19:36.867: E/AndroidRuntime(27101): at java.lang.reflect.Method.invokeNative(Native Method)
02-16 00:19:36.867: E/AndroidRuntime(27101): at java.lang.reflect.Method.invoke(Method.java:511)
02-16 00:19:36.867: E/AndroidRuntime(27101): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
02-16 00:19:36.867: E/AndroidRuntime(27101): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
02-16 00:19:36.867: E/AndroidRuntime(27101): at dalvik.system.NativeStart.main(Native Method)
02-16 00:19:36.867: E/AndroidRuntime(27101): Caused by: java.lang.ClassCastException: com.android.internal.policy.impl.PhoneLayoutInflater cannot be cast to org.holoeverywhere.LayoutInflater
02-16 00:19:36.867: E/AndroidRuntime(27101): at com.twk95.lchs.browser.ImageAndTextAdapter.<init>(ImageAndTextAdapter.java:27)
02-16 00:19:36.867: E/AndroidRuntime(27101): at com.twk95.lchs.browser.Main.onCreate(Main.java:76)
02-16 00:19:36.867: E/AndroidRuntime(27101): at android.app.Activity.performCreate(Activity.java:5104)
02-16 00:19:36.867: E/AndroidRuntime(27101): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-16 00:19:36.867: E/AndroidRuntime(27101): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2260)
02-16 00:19:36.867: E/AndroidRuntime(27101): ... 11 more
02-16 00:19:36.875: E/InputManager-JNI(379): java.lang.NullPointerException
02-16 00:19:36.875: E/InputManager-JNI(379): at com.android.internal.policy.impl.PhoneWindowManager.interceptKeyBeforeQueueing(PhoneWindowManager.java:3832)
02-16 00:19:36.875: E/InputManager-JNI(379): at com.android.server.wm.InputMonitor.interceptKeyBeforeQueueing(InputMonitor.java:337)
02-16 00:19:36.875: E/InputManager-JNI(379): at com.android.server.input.InputManagerService.interceptKeyBeforeQueueing(InputManagerService.java:1317)
02-16 00:19:36.875: E/InputManager-JNI(379): at dalvik.system.NativeStart.run(Native Method)`
より多くのコードが必要な場合は、質問してください。助けてくれてありがとう!
編集:コードを追加しました。また、system32とebarrencheaの提案は機能しませんでした。EDIT2:私自身の質問に答えました。以下の解決策