1
我想獲取Arraylist(這裏albumArrayList)的圖像來設置ImageSwitcher.But中的視圖,但無法獲取圖像。請幫我解決這個問題..謝謝。 。如何獲取ImagesReader視圖上的ArrayList
public class ImageViewActivity extends Activity{
public static Gallery iGllry;
public static ImageSwitcher imageSwitcher;
public static ImageLoader imageLoader;
public static ArrayList<AddAlbumDetailBean> album_photos1;
public static AddAlbumDetailBean album_photo1;
public static ArrayList<Integer> albumArrayList;
public static Integer albumarrayob;
public static ArrayList<Integer> albumArrayList2;
public static Integer albumarrayob2;
public static ArrayList<Bitmap> ablum_photosbit;
public static Bitmap albmphtbit;
public static ImageView imgvwfrgallery;
public static GridActivity gridActivity;
//public static int position = gridActivity.posi;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.imageviewactivity);
iGllry = (Gallery) findViewById(R.id.img_glry);
album_photos1 = GridActivity.albumPhotos;
int count1 = album_photos1.size();
Log.i("array of images", ""+ count1);
albumArrayList= new ArrayList<Integer>();
for(int i=0;i<album_photos1.size();i++){
albumArrayList.add(albumarrayob);
}
int count = albumArrayList.size();
Log.i("Array of images in integer array",""+count);
imgvwfrgallery= (ImageView)findViewById(R.id.imgvwfrgllry);
iGllry.setAdapter(new EfficientAdapter1(this));
iGllry.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v, int position,long id) {
// TODO Auto-generated method stub
Log.e("Enters in click event of gallery","GALLERY");
imgvwfrgallery.setImageResource(albumArrayList.indexOf(album_photo1));
Toast.makeText(getApplicationContext(), "Position "+(position+1), Toast.LENGTH_SHORT).show();
}
});
}
public class EfficientAdapter1 extends BaseAdapter{
private Context mContext1;
private LayoutInflater mInflater1;
ImageLoader imageLoader;
int count;
public EfficientAdapter1(ImageViewActivity imageViewActivity) {
// TODO Auto-generated constructor stub
mInflater1 = LayoutInflater.from(imageViewActivity);
mContext1 = imageViewActivity;
imageLoader = new ImageLoader(mContext1);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
Log.e("no. of photos in arraylist COUNT", ""+album_photos1.size());
return album_photos1.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
//return 0;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
//return 0;
}
@Override
public View getView(int position, View convertView1, ViewGroup parent) {
// TODO Auto-generated method stub
ImageView imageView = new ImageView(mContext1);
album_photo1 = album_photos1.get(position);
Log.i("album photos get view ", ""+album_photo1);
Log.i("Position in getview ", ""+position);
imageView.setTag(album_photo1.getUrl());
imageLoader.DisplayImage(album_photo1.getUrl(),false,imageView);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
return imageView;
}
}
LOG CAT:
07-27 11:32:01.478: WARN/dalvikvm(4539): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): FATAL EXCEPTION: main
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): android.content.res.Resources$NotFoundException: Resource ID #0xffffffff
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.content.res.Resources.getValue(Resources.java:892)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.content.res.Resources.getDrawable(Resources.java:580)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.view.View.setBackgroundResource(View.java:7533)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at com.ijoomer.ImageViewActivity$1.onItemClick(ImageViewActivity.java:142)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.widget.Gallery.onSingleTapUp(Gallery.java:867)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.view.GestureDetector.onTouchEvent(GestureDetector.java:557)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.widget.Gallery.onTouchEvent(Gallery.java:842)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.view.View.dispatchTouchEvent(View.java:3885)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.view.ViewRoot.handleMessage(ViewRoot.java:1878)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.os.Handler.dispatchMessage(Handler.java:99)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.os.Looper.loop(Looper.java:123)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at android.app.ActivityThread.main(ActivityThread.java:3647)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at java.lang.reflect.Method.invokeNative(Native Method)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at java.lang.reflect.Method.invoke(Method.java:507)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-27 11:32:01.508: ERROR/AndroidRuntime(4539): at dalvik.system.NativeStart.main(Native Method)
07-27 11:32:01.538: WARN/ActivityManager(61): Force finishing activity com.ijoomer/.ImageViewActivity
在此以下行在我的代碼 java.lang.reflect.Field中[]字段= albumArrayList.getClass()getDeclaredFields(); 我可以用什麼來代替albumArrayList.getClass()。 – Saurabh
根據我剛剛刪除albumarray,只是把簡單的整數數組。如果你想只是圖像切換器複製我的代碼改變圖像在圖片[]。 – Siten
我想要的圖像是在另一個活動,所以我使用arraylist。 – Saurabh