小编T.S*_*.S.的帖子

在TextView中动态加载AnimationDrawable

我需要用图像替换文本中的短语,然后将其附加到TextView.对于常规Drawables,这没有问题,但是当Drawable是AnimationDrawable时,我不知道在何时何地调用.start();.

这是我将文本追加到TextView的方法:

textview.append(Html.fromHtml(textWithHtmlImgTags, imagegetter, null));
Run Code Online (Sandbox Code Playgroud)

使用imagegetter替换textWithHtmlImgTags中的图像标记:

new ImageGetter()
{
    @Override
    public Drawable getDrawable(String source) {

        if(source.endsWith("_ani"))
        {
            Log.i("cmv", "This is an animated drawable.");

            AnimationDrawable dra = (AnimationDrawable)res.getDrawable(sRes.get(source));
            dra.setBounds(0, 0, dra.getIntrinsicWidth(), dra.getIntrinsicHeight());
            dra.start(); // This doesn't work..

            return dra;
        }

        Drawable dr = res.getDrawable(sRes.get(source));
        dr.setBounds(0, 0, dr.getIntrinsicWidth(), dr.getIntrinsicHeight());
        return dr;
    }

};
Run Code Online (Sandbox Code Playgroud)

添加了我的AnimationDrawables,但它们没有动画(它们被卡在第1帧上).

在文档中它说:

重要的是要注意,在Activity的onCreate()方法中,无法调用在AnimationDrawable上调用的start()方法,因为AnimationDrawable尚未完全附加到窗口.如果您想立即播放动画而不需要交互,那么您可能希望从Activity中的onWindowFocusChanged()方法调用它,当Android将窗口置于焦点时将调用它.

由于图像是动态添加的,我认为它与onCreate()没有任何关系.所以我想我可以.start()在我的抽签时给我打电话is not yet fully attached to the window,但我应该在何处/何时/怎么称呼它?

提前致谢!

animation android drawable

8
推荐指数
1
解决办法
3121
查看次数

检查open_basedir限制是否生效

使用PHPass(http://www.openwall.com/phpass/)时收到以下警告:

open_basedir restriction in effect. File(/dev/urandom) is not within the allowed path(s)
Run Code Online (Sandbox Code Playgroud)

虽然这不是一个大问题(它会落后于其他东西),但我不想发出这个警告.PHP应用程序应该在不同的服务器上运行,一些用户可以将该路径添加到其允许的open_basedir路径,但其他用户将无法访问该配置.

我的第一个猜测是检查可读性is_readable(),但是,我仍然收到警告.

问题:如何检查某个路径或文件是否已添加到open_basedir路径?

php open-basedir phpass

8
推荐指数
1
解决办法
5173
查看次数

标签 统计

android ×1

animation ×1

drawable ×1

open-basedir ×1

php ×1

phpass ×1