- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我将一个项目从 Eclipse 迁移到了 Android Studio。在我的项目中,我添加了 this library .我已将该库作为依赖项添加到我的 gradle
文件中。我可以从我的类(class)导入图书馆。
但它显示了这一点
android.view.InflateException:二进制 XML 文件第 8 行:错误膨胀类 com.digitalaria.gama.wheel.Wheel
在运行应用程序时。
注意 - 从 Eclipse 运行它时它工作正常。
渐变
apply plugin: 'android'
dependencies {
// compile fileTree(dir: 'libs', include: '*.jar')
compile project(':RemoteIt Protocol')
compile project(':android-support-v7-appcompat')
compile files('libs/gama_wheel_v1.0.jar')
compile files('libs/PayPalAndroidSDK.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<com.digitalaria.gama.wheel.Wheel
android:id="@+id/wheel"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</com.digitalaria.gama.wheel.Wheel>
</LinearLayout>
类
import com.digitalaria.gama.wheel.Wheel;
import com.digitalaria.gama.wheel.WheelAdapter;
public class Home extends MainActivity implements OnClickListener
{
private RemoteIt application;
private SharedPreferences preferences;
@Override
protected void onCreate(Bundle savedInstanceState)
{
this.application = (RemoteIt) this.getApplication();
this.preferences = this.application.getPreferences();
super.onCreate(savedInstanceState);
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(s);
this.checkOnCreate();
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View contentView = inflater.inflate(R.layout.home, null, false);
mDrawer.addView(contentView, 0);
init();
wheel();
}
private void wheel()
{
wheel.setOnItemClickListener(new WheelAdapter.OnItemClickListener()
{
@Override
public void onItemClick(WheelAdapter<?> parent, View view, int position, long id)
{
switch (position)
{
case 0:
Intent ac = new Intent(Home.this, ConnectionListActivity.class);
startActivity(ac);
break;
case 1:
Intent b = new Intent(Home.this, ControlActivity.class);
startActivity(b);
break;
case 2:
Intent c = new Intent(Home.this, FileExplorerActivity.class);
startActivity(c);
// this.toggleKeyboard();
break;
case 3:
Intent d = new Intent(Home.this, Presentation.class);
startActivity(d);
break;
case 4:
Intent e = new Intent(Home.this, Media.class);
startActivity(e);
break;
case 5:
Intent f = new Intent(Home.this, Shortcuts.class);
startActivity(f);
break;
case 6:
Intent g = new Intent(Home.this, Browser.class);
startActivity(g);
break;
}
}
});
}
private Wheel wheel;
private Resources res;
private int[] icons = {
R.drawable.conn, R.drawable.mouse, R.drawable.file, R.drawable.present, R.drawable.media, R.drawable.shortc, R.drawable.browser
};
private void init()
{
res = getApplicationContext().getResources();
wheel = (Wheel) findViewById(R.id.wheel);
wheel.setItems(getDrawableFromData(icons));
wheel.setWheelDiameter((int) getResources().getDimension(R.dimen.diameter));
}
private Drawable[] getDrawableFromData(int[] data)
{
Drawable[] ret = new Drawable[data.length];
for (int i = 0; i < data.length; i++)
{
ret[i] = res.getDrawable(data[i]);
}
return ret;
}
LogCat
Process: com.RemoteIt.client, PID: 1825
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.RemoteIt.client/com.RemoteIt.client.activity.Home}: android.view.InflateException: Binary XML file line #8: Error inflating class com.digitalaria.gama.wheel.Wheel
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.digitalaria.gama.wheel.Wheel
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.RemoteIt.client.activity.Home.onCreate(Home.java:50)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.RemoteIt.client.activity.Home.onCreate(Home.java:50)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsupportedOperationException: Can't convert to integer: type=0x3
at android.content.res.TypedArray.getInteger(TypedArray.java:368)
at com.digitalaria.gama.wheel.WheelBehavior.<init>(WheelBehavior.java:117)
at com.digitalaria.gama.wheel.Wheel.<init>(Wheel.java:83)
at com.digitalaria.gama.wheel.Wheel.<init>(Wheel.java:68)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.RemoteIt.client.activity.Home.onCreate(Home.java:50)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Wheel.java
public final class Wheel extends android.widget.FrameLayout {
public static final int CCW = -1;
public static final int CW = 1;
private com.digitalaria.gama.wheel.WheelBehavior _wheelBehavior;
private android.view.ViewStub _backgroundViewDummy;
protected android.view.View _backgroundView;
protected boolean _hasBackgroundImage;
private android.widget.FrameLayout.LayoutParams params;
private int _reservedPositionLeft;
private int _reservedPositionTop;
private boolean isLayout;
private int _storedLeft;
private int _storedTop;
private int _storedRight;
private int _storedBottom;
private int _centerX;
private int _centerY;
public Wheel(android.content.Context context) { /* compiled code */ }
public Wheel(android.content.Context context, android.util.AttributeSet attrs) { /* compiled code */ }
public Wheel(android.content.Context context, android.util.AttributeSet attrs, int defStyle) { /* compiled code */ }
protected void onLayout(boolean changed, int l, int t, int r, int b) { /* compiled code */ }
public void addView(android.view.View child) { /* compiled code */ }
public void addView(android.view.View child, int index) { /* compiled code */ }
public void removeView(android.view.View child) { /* compiled code */ }
public void removeViewAt(int index) { /* compiled code */ }
public float getCenterX() { /* compiled code */ }
public float getCenterY() { /* compiled code */ }
public final void setOnItemClickListener(com.digitalaria.gama.wheel.WheelAdapter.OnItemClickListener listener) { /* compiled code */ }
public final com.digitalaria.gama.wheel.WheelAdapter.OnItemClickListener getOnItemClickListener() { /* compiled code */ }
public final void setOnWheelRotationListener(com.digitalaria.gama.wheel.WheelAdapter.OnWheelRotationListener listener) { /* compiled code */ }
public final com.digitalaria.gama.wheel.WheelAdapter.OnWheelRotationListener getOnWheelRotationListener() { /* compiled code */ }
public void setOnItemSelectionUpdatedListener(com.digitalaria.gama.wheel.WheelAdapter.OnItemSelectionUpdatedListener listener) { /* compiled code */ }
public void setPosition(int left, int top) { /* compiled code */ }
public void setSelectionAngle(int angle) { /* compiled code */ }
public void setItems(android.content.res.TypedArray items) { /* compiled code */ }
public void setItems(android.graphics.drawable.Drawable[] drawables) { /* compiled code */ }
public void setWheelDiameter(int diameter) { /* compiled code */ }
public void setWheelBackground(int inflatedId, int layoutResource) { /* compiled code */ }
public void setRotatedItem(boolean flag) { /* compiled code */ }
public void configureWheelBackground(int initRotationAngle, boolean rotatedItem) { /* compiled code */ }
public void configureWheelBackground(boolean rotatedItem) { /* compiled code */ }
protected boolean hasBackgroundImage() { /* compiled code */ }
public void setTouchArea(int from, int to) { /* compiled code */ }
public int nextItem() { /* compiled code */ }
public int previousItem() { /* compiled code */ }
public boolean isRotationFinished() { /* compiled code */ }
public void flingStartUsingAngle(float angle) { /* compiled code */ }
public void flingStartUsingVelocity(int vx, int vy, boolean scroolToSlot) { /* compiled code */ }
public void flingStartUsingVelocityWithDirection(int vx, int vy, int direction) { /* compiled code */ }
public int getSelectedItem() { /* compiled code */ }
public int getSelectedItem(boolean stopScroll) { /* compiled code */ }
public boolean setSelectedItem(int index) { /* compiled code */ }
public void setItemClickEventAtSelectionPosition(boolean enable) { /* compiled code */ }
public boolean getItemClickEventAtSelectionPosition() { /* compiled code */ }
public void setEnabled(boolean enabled) { /* compiled code */ }
public boolean isLayouted() { /* compiled code */ }
}
最佳答案
相关异常:
Caused by: java.lang.UnsupportedOperationException: Can't convert to integer: type=0x3
at android.content.res.TypedArray.getInteger(TypedArray.java:368)
at com.digitalaria.gama.wheel.WheelBehavior.<init>(WheelBehavior.java:117)
WheelBehavior.java,第 117 行
setWheelDiameter(arr.getInteger(R.styleable.Wheel_wheel_diameter, Configuration.DEFAULT_WHEEL_DIAMETER));
以下是样式属性:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="Wheel">
<attr name="wheel_rotation_duration" format="integer"/> <!-- default:400 -->
<attr name="wheel_diameter" format="integer"/> <!-- default:250 -->
<attr name="items" format="integer"/>
<attr name="item_selected_index" format="integer"/>
</declare-styleable>
</resources>
wheel_diameter
必须在您的项目中的某处定义,其中包含除整数以外的其他内容。这就是它崩溃的原因。但是根据你的布局,它不是。尝试对字符串 wheel_diameter
关于java - 充气类时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26729809/
SQLite、Content provider 和 Shared Preference 之间的所有已知区别。 但我想知道什么时候需要根据情况使用 SQLite 或 Content Provider 或
警告:我正在使用一个我无法完全控制的后端,所以我正在努力解决 Backbone 中的一些注意事项,这些注意事项可能在其他地方更好地解决......不幸的是,我别无选择,只能在这里处理它们! 所以,我的
我一整天都在挣扎。我的预输入搜索表达式与远程 json 数据完美配合。但是当我尝试使用相同的 json 数据作为预取数据时,建议为空。点击第一个标志后,我收到预定义消息“无法找到任何内容...”,结果
我正在制作一个模拟 NHL 选秀彩票的程序,其中屏幕右侧应该有一个 JTextField,并且在左侧绘制弹跳的选秀球。我创建了一个名为 Ball 的类,它实现了 Runnable,并在我的主 Draf
这个问题已经有答案了: How can I calculate a time span in Java and format the output? (18 个回答) 已关闭 9 年前。 这是我的代码
我有一个 ASP.NET Web API 应用程序在我的本地 IIS 实例上运行。 Web 应用程序配置有 CORS。我调用的 Web API 方法类似于: [POST("/API/{foo}/{ba
我将用户输入的时间和日期作为: DatePicker dp = (DatePicker) findViewById(R.id.datePicker); TimePicker tp = (TimePic
放宽“邻居”的标准是否足够,或者是否有其他标准行动可以采取? 最佳答案 如果所有相邻解决方案都是 Tabu,则听起来您的 Tabu 列表的大小太长或您的释放策略太严格。一个好的 Tabu 列表长度是
我正在阅读来自 cppreference 的代码示例: #include #include #include #include template void print_queue(T& q)
我快疯了,我试图理解工具提示的行为,但没有成功。 1. 第一个问题是当我尝试通过插件(按钮 1)在点击事件中使用它时 -> 如果您转到 Fiddle,您会在“内容”内看到该函数' 每次点击都会调用该属
我在功能组件中有以下代码: const [ folder, setFolder ] = useState([]); const folderData = useContext(FolderContex
我在使用预签名网址和 AFNetworking 3.0 从 S3 获取图像时遇到问题。我可以使用 NSMutableURLRequest 和 NSURLSession 获取图像,但是当我使用 AFHT
我正在使用 Oracle ojdbc 12 和 Java 8 处理 Oracle UCP 管理器的问题。当 UCP 池启动失败时,我希望关闭它创建的连接。 当池初始化期间遇到 ORA-02391:超过
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve
引用这个plunker: https://plnkr.co/edit/GWsbdDWVvBYNMqyxzlLY?p=preview 我在 styles.css 文件和 src/app.ts 文件中指定
为什么我的条形这么细?我尝试将宽度设置为 1,它们变得非常厚。我不知道还能尝试什么。默认厚度为 0.8,这是应该的样子吗? import matplotlib.pyplot as plt import
当我编写时,查询按预期执行: SELECT id, day2.count - day1.count AS diff FROM day1 NATURAL JOIN day2; 但我真正想要的是右连接。当
我有以下时间数据: 0 08/01/16 13:07:46,335437 1 18/02/16 08:40:40,565575 2 14/01/16 22:2
一些背景知识 -我的 NodeJS 服务器在端口 3001 上运行,我的 React 应用程序在端口 3000 上运行。我在 React 应用程序 package.json 中设置了一个代理来代理对端
我面临着一个愚蠢的问题。我试图在我的 Angular 应用程序中延迟加载我的图像,我已经尝试过这个2: 但是他们都设置了 src attr 而不是 data-src,我在这里遗漏了什么吗?保留 d
我是一名优秀的程序员,十分优秀!