Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓,有两个问题_Android - Fatal编程技术网

Android 安卓,有两个问题

Android 安卓,有两个问题,android,Android,我正在使用,我有一个问题和一个问题: 1.为什么findViewById()总是返回null 2.如何使图像因持续时间而变得模糊?我的意思是从blur=0开始,然后在5秒钟内将其增加到blur=201-我认为您正在使用findViewById()检索当前布局中未显示的视图(无法准确说明您没有显示代码,因此我无法确定如何实现stackblur),因此,尝试对包含视图的布局充气,然后通过其实例获取元素: LayoutInflater inflater = (LayoutInflater) Curre

我正在使用,我有一个问题和一个问题:

1.为什么
findViewById()
总是返回
null


2.如何使图像因持续时间而变得模糊?我的意思是从
blur=0
开始,然后在5秒钟内将其增加到
blur=20

1-我认为您正在使用
findViewById()
检索当前布局中未显示的
视图(无法准确说明您没有显示代码,因此我无法确定如何实现stackblur),因此,尝试对包含
视图
布局
充气
,然后通过其实例获取元素:

LayoutInflater inflater = (LayoutInflater) CurrentActivity.this
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.layout_contains_the_view,
                        (ViewGroup) findViewById(R.id.main_view_in_that_layout));
// So, for example if you want to get a TextView
TextView text = (TextView) layout.findViewById(R.id.text_view_name);
2-用于使图像模糊0逐渐增加到20

    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            int blur = 0;
            set_image_blur(blur);
            for(int i =0; i < 5000; i++){
                blur = blur + (20*(i/5000));
                set_image_blur(blur);
            }
        }
    });
runOnUiThread(新的Runnable(){
@凌驾
公开募捐{
整数模糊=0;
设置图像模糊(模糊);
对于(int i=0;i<5000;i++){
模糊=模糊+(20*(i/5000));
设置图像模糊(模糊);
}
}
});