安卓中的 ImageView
来源:互联网 发布:阿里云搭建网站 编辑:程序博客网 时间:2024/05/16 19:12
在读《Android.Apps.for.Absolute.Beginners》,非常适合初学者。 虽然是英文的,可是看了快一本了感觉所需的单词量还不到四级的要求。 相比看中文的安卓开发初级,似乎作者都是急着挣稿费的,很多地方只会教你怎么做而讲不出原理。 可英文书不但详尽的的把每一个步骤都列出来或直接上截图,并且还经常点拨一下难懂的概念。就像下面所列举的一样(p142):
@Override
public boolean onOptionsItemSelected(MenuItem item) {
LinearLayout bkgr= (LinearLayout)findViewById(R.id.uilayout);
final ImageView image=(ImageView)findViewById(R.id.imageView1);
AlertDialog.Builder builder=new AlertDialog.Builder(this);
Here is the code to customize our dialog:
builder.setTitle("Pick an Image!")
.setMessage("Please Select Image One or Image Two:")
.setCancelable(false)
.setPositiveButton("IMAGE 1", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id) {
image.setImageResource(R.drawable.image1);
}
})
.setNegativeButton("IMAGE 2", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
image.setImageResource(R.drawable.image2);
}
});
We work with the image object, which we know can’t be reassigned a value because it is final. This is to deal with situations where the event listener is used after the onOptionsItemSelected() method has terminated. In this case, a non-final image variable would not be around to take a new assignment, whereas a final variable is frozen in memory for access at all times (of course, this may never happen, but Java was built this way just to be sure).
“a non-final image variable would not be around to take a new assignment”这句话是否可理解为:一个非final类型的image变量将不能被分配新值? 可是这不正是final的特性么? 该怎么理解?
- 安卓中的 ImageView
- 安卓简单自定义ImageView
- 安卓自定义圆形imageview
- 安卓圆形imageview笔记
- 安卓自定义圆形imageview
- 安卓开发之ImageView
- 安卓开发34:ImageView API
- 安卓 有关动态加载ImageView,Radiobutton
- 安卓 ImageView动态改变大小
- 安卓ImageView显示SVG图片
- 安卓使用ImageView显示OpenCV-Mat
- 安卓imageview获取网络图片
- 安卓基本控件之ImageView
- 安卓布局,控件imageview,ListView
- 安卓 ImageView ACTION_UP&DOWN监听
- 安卓 ImageView伸缩放大缩小
- 安卓ImageView的 src和background
- 安卓 imageview旋转 回弹 matrix
- 我思我故在
- STM32入门笔记(1)——时钟
- EclipseEE版本中配置Tomcat发布Web项目及相关
- hdu 1712
- 等概率获取随机数
- 安卓中的 ImageView
- 和最大的连续子串
- Ubuntu12.04 搭建TFTP服务
- USACO_1.1_beads
- 营业额统计问题的三种巧妙解法
- JavaScript自学ing(2)
- RQNOJ 38(串的计数)
- 关于bitlocker加密后的格式化
- Vim与Emacs使用体会