在不同的进程膨胀的自定义视图(Xposed) [英] Inflating custom view in different process (Xposed)

查看:206
本文介绍了在不同的进程膨胀的自定义视图(Xposed)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个Xposed模块并想用一个自定义的视图类(类是相当复杂的,所以/只能使用系统UI元素我不能重新建立)。按照由GravityBox开发这个后,它应该是可能的(虽然困难)。我看着他张贴的提示(<一个href=\"https://github.com/GravityBox/GravityBox/blob/kitkat/src/com/ceco/kitkat/gravitybox/quicksettings/BasicTile.java\"相对=nofollow> BasicTile.java ),但我无法将此应用到我的情况。

I'm developing an Xposed-module and would like to use a custom view class (the class is rather complex, so I can't recreate it from scratch/only using system UI elements). As per this post by the GravityBox dev, it should be possible (albeit difficult). I've looked at the hint he posted (BasicTile.java), but am unable to apply this to my situation.

我想使用 SlidingUpPanel -library我的模块,如果我用它工作正常它作为我模块的设置活动(例如)的内容,但无法用 ClassNotFound的 -exception当它从Xposed桥过程中。

I'd like to use the SlidingUpPanel-library in my module, which works fine if I use it as the content of my module's settings-activity (for example), but fails with a ClassNotFound-exception when it's used from the Xposed-bridge-process.

推荐答案

实例化在code类(从您的应用程序的包创建上下文)的作品(而来自XML夸大事实并非如此)。

Instantiating the class in code (with a context created from your app's package) works (while inflating it from xml does not).

,使这项工作方式:结果
- 添加一个空的&LT;视图&gt; 占位符在XML(而不是自定义视图本身)结果
- 在你的code,充气XML的布局结果
- 编程创建自定义视图类的一个实例,并将其添加为孩子查看占位符:

The way to make this work:
- Add an empty <View> placeholder in your xml (instead of the custom view itself)
- In your code, inflate the xml-layout
- Programmatically create an instance of your custom view class and add it as a child to the View placeholder:

的ViewGroup mContainer =(ViewGroup中)yourInflatedView.findViewById(R.id.container);
YourCustomViewClass mCustomView =新YourCustomViewClass(背景);
mContainer.addView(mCustomView);

这篇关于在不同的进程膨胀的自定义视图(Xposed)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆