public Object instantiateItem(ViewGroup container, int position) {
ImageView view = new ImageView();
container.addView(view);
return view;
}
Run Code Online (Sandbox Code Playgroud)
我读了一些PagerAdapter的示例代码,他们都编写了addview方法.以上是一些简单的代码,而且我知道'return view'用于返回显示的视图,但是container.addView(view)是什么呢?
当我使用copyPixelsFromBuffer和copyPixelsToBuffer时,位图没有显示为相同的位图,我试过下面的代码:
Bitmap bm = BitmapFactory.decodeByteArray(a, 0, a.length);
int[] pixels = new int[bm.getWidth() * bm.getHeight()];
bm.getPixels(pixels, 0, bm.getWidth(), 0, 0,bm.getWidth(),bm.getHeight());
ByteBuffer buffer = ByteBuffer.allocate(bm.getRowBytes()*bm.getHeight());
bm.copyPixelsToBuffer(buffer);//I copy the pixels from Bitmap bm to the buffer
ByteBuffer buffer1 = ByteBuffer.wrap(buffer.array());
newbm = Bitmap.createBitmap(160, 160,Config.RGB_565);
newbm.copyPixelsFromBuffer(buffer1);//I read pixels from the Buffer and put the pixels to the Bitmap newbm.
imageview1.setImageBitmap(newbm);
imageview2.setImageBitmap(bm);
Run Code Online (Sandbox Code Playgroud)
为什么Bitmap bm和newbm没有显示相同的内容?
我写了一个名为T的线程类.
我的目的是确保一次只运行一个线程对象.
因此,当调用线程对象时,它将检查一个名为BUSY的布尔标志.
我的问题是什么是不同的
private static AtomicBoolean BUSY = new AtomicBoolean(false);
Run Code Online (Sandbox Code Playgroud)
和
private static boolean BUSY = false;
Run Code Online (Sandbox Code Playgroud)
我想如果使用'static',所有对象只会检查一个BUSY布尔变量,这样才能确保只有一个线程对象在运行.
我print("Helloworld")在代码中使用了函数,输出打印在哪里?
我没有找到一个可以使PNG图片的透明区域没有被触摸的变量.DisplayObject是否具有可以使透明区域无法触及的功能或变量?
感谢您的回答.
我读了源代码,只有一个管道将所有中间件作为数组读取。这些中间件应该在请求之前运行dispatchToRouter.
return (new Pipeline($this->app))
->send($request)
->through($this->app->shouldSkipMiddleware() ? [] : $this->middleware)
->then($this->dispatchToRouter());
Run Code Online (Sandbox Code Playgroud)
但是,如果我创建了一个后置中间件,则该后置中间件应该在请求处理后运行。这里以及何时在 Laravel 源代码中执行后置中间件?