@Override public void handleMessage(Message msg) { // TODO Auto-generated method stub super.handleMessage(msg); switch (msg.what) { case INIT_FINISH: mGallery.setVerticalFadingEdgeEnabled(false); mGallery.setHorizontalFadingEdgeEnabled(false); mGallery.setAdapter(new GalleryAdapter(mContext, imagesPath)); mGallery.setSelection(index); break; default: break; } }
public void onActivityCreated(Bundle savedInstanceState) { Log.i("onActivityCreated", "child"); super.onCreate(savedInstanceState); PrepArrows(); Gallery gallery = (Gallery) getView().findViewById(R.id.gallery); gallery.setAdapter(new ImageAdapter(this.getActivity().getBaseContext(), mImageIds)); gallery.setHorizontalFadingEdgeEnabled(true); gallery.setOnItemSelectedListener( new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View v, int position, long id) { int i = parent.getCount(); Log.i("OnItemSelected", Integer.toString(position) + " / " + Integer.toString(i)); for (int x = 0; x < i; x++) { View vv = parent.getChildAt(x); if (vv != null) { vv.setAlpha(128); vv.setBackgroundResource(0); } } v.setAlpha(255); parent.invalidate(); ToggleArrows(position); // Update the CSDL Summary UpdateGUI(position); } @Override public void onNothingSelected(AdapterView<?> parent) { Log.i("onNothingSelected", "Nothing selected?"); int i = parent.getCount(); for (int x = 0; x < i; x++) { parent.getChildAt(x).setAlpha(128); parent.getChildAt(x).setBackgroundResource(0); } } }); // Set this after the listener to cheat on setting the alpha gallery.setSelection(4, true); }