drawable文件夹中的图像是int数据类型?

时间:2015-06-05 00:57:51

标签: android

从网络教程中,我得到了这段代码:

is_balanced( T ) :- is_balanced( T, _ ) .

is_balanced( nil         , 0 ) .   % the empty tree is balanced and has a height of zero.
is_balanced( tree(_,L,R) , H ) :-  % a non-empty tree is balanced IF ...
  is_balanced( L , LH ) ,          % - its left subtree is balanced, and
  is_balanced( R , RH ) ,          % - its right subtree is balanced, and 
  abs( LH - RH) < 2 ,              % - their respective heights differ by no more than 1, and
  H is 1 + max( LH , RH )          % - the current tree's height is 1 more than the larger of the heights of the two subtrees.
  .                                % Easy! (And elegant!)

来自public class ImageAdapter extends PagerAdapter { Context context; private int[] GalImages = new int[] {R.drawable.one, R.drawable.two, R.drawable.three}; ImageAdapter(Context context) { this.context = context; } @Override public int getCount() { return GalImages.length; } @Override public boolean isViewFromObject(View view, Object object) { return view == ((ImageView) object); } @Override public Object instantiateItem(ViewGroup container, int position) { ImageView imageView = new ImageView(context); int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_medium); imageView.setPadding(padding, padding, padding, padding); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); imageView.setImageResource(GalImages[position]); ((ViewPager) container).addView(imageView, 0); return imageView; } @Override public void destroyItem(ViewGroup container, int position, Object object) { ((ViewPager) container).removeView((ImageView) object); } } 部分
我的问题是为什么图像文件可以存储在整数数据类型中?如果我将private int[] GalImages = new int[] {R.drawable.one, R.drawable.two, R.drawable.three};更改为我设备中的其他图像,是否可以?例如:R.drawable.one, R.drawable.two, R.drawable.three

1 个答案:

答案 0 :(得分:0)

您的Drawable数据类型不是int;您对它的引用是int,您可以在R.java中看到。

不,你不能在运行时更改这些引用。

如果您查看了R.java文件,可以看到它已声明为final

实施例: public static final int actionBarSize=0x7f010062;