Example usage for android.widget Gallery setAdapter

List of usage examples for android.widget Gallery setAdapter

Introduction

In this page you can find the example usage for android.widget Gallery setAdapter.

Prototype

@Override
public void setAdapter(SpinnerAdapter adapter) 

Source Link

Document

The Adapter is used to provide the data which backs this Spinner.

Usage

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.ObjCommentsFragment.java

/**
 * The parametrization here is absolutely not final.
 *//*from w w w .j  a  v a2 s .c om*/
public static View getViewForObjComments(Activity activity, Uri feedUri, JSONObject obj) {

    Cursor c = activity.getContentResolver().query(feedUri, null, DbObjects.getFeedObjectClause(null), null,
            DbObject._ID + " DESC LIMIT 2");
    try {
        SpinnerAdapter adapter = new ObjectListCursorAdapter(activity, c);

        Gallery gallery = new Gallery(activity);
        gallery.setLayoutParams(CommonLayouts.FULL_SCREEN);
        gallery.setAdapter(adapter);

        return gallery;
    } finally {
        c.close();
    }
}

From source file:org.sociotech.fishification.ui.fragments.FeedFishFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    m_view = inflater.inflate(R.layout.fragment_fish_feed, container, false);
    m_defaultBackground = m_view.getBackground();

    // Init Gallery
    Gallery gallery = (Gallery) m_view.findViewById(R.id.fishBoxGallery);
    gallery.setAdapter(new FishFoodBoxAdapter(m_view.getContext()));

    // Init Sensor
    Context context = m_view.getContext();
    m_sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
    m_lastUpdate = System.currentTimeMillis();

    return m_view;
}

From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedHistoryFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mAdapter = getListAdapter(getActivity(), mFeedUri);
    Gallery gallery = new Gallery(getActivity());
    gallery.setLayoutParams(CommonLayouts.FULL_SCREEN);
    gallery.setAdapter(mAdapter);
    gallery.setOnItemClickListener(this);
    return gallery;
}

From source file:edu.mit.mobile.android.locast.ver2.casts.CastDetail.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.cast_detail);

    initOverlays();/*from w  w w.j  a v a  2s  .c om*/

    final Uri data = getIntent().getData();

    mCastMediaUri = Cast.getCastMediaUri(data);

    mMapController = ((MapView) findViewById(R.id.map)).getController();
    mLoaderManager = getSupportLoaderManager();
    mLoaderManager.initLoader(LOADER_CAST, null, this);
    mLoaderManager.initLoader(LOADER_CAST_MEDIA, null, this);
    findViewById(R.id.home).setOnClickListener(this);
    findViewById(R.id.refresh).setOnClickListener(this);

    vcb = (ValidatingCheckBox) findViewById(R.id.favorite);

    vcb.setValidatedClickHandler(new MyFavoriteClickHandler(this, data));

    final Gallery castMediaView = (Gallery) findViewById(R.id.cast_media);

    mCastMedia = new CastMediaAdapter(this);

    castMediaView.setEmptyView(findViewById(android.R.id.empty));
    castMediaView.setAdapter(new ImageLoaderAdapter(this, mCastMedia, ImageCache.getInstance(this),
            new int[] { R.id.media_thumbnail }, 480, 360, ImageLoaderAdapter.UNIT_DIP));

    castMediaView.setOnItemClickListener(this);

    castMediaView.setEnabled(true);

    final String action = getIntent().getAction();
    if (Intent.ACTION_DELETE.equals(action)) {
        showDialog(DIALOG_CONFIRM_DELETE);
    }
}

From source file:com.liquid.wallpapers.free.ScroidWallpaperGallery.java

private synchronized void updateGalleryAdapter(Wallpaper[] wallpapers) {
    this.wallpaperGalleryAdapter = new WallpaperGalleryAdapter(this, wallpapers, this.wallpaperManager);

    Gallery gallery = (Gallery) this.findViewById(R.id.gallery);
    gallery.setAdapter(this.wallpaperGalleryAdapter);
}

From source file:mobisocial.musubi.objects.IntroductionObj.java

@Override
public void render(Context context, final View frame, DbObjCursor obj, final boolean allowInteractions) {
    Gallery intro = (Gallery) ((ViewGroup) frame).getChildAt(1);

    // TODO: LoaderManager requires access to a SupportActivity.
    intro.setAdapter(FacesAdapter.forObj(context, obj));
    intro.setSpacing(1);/*from  w ww  .  j a v a  2  s.com*/
    intro.setOnItemClickListener(mIdentityClickListener);
}

From source file:edu.mit.mobile.android.locast.casts.CastDetail.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.cast_detail);

    mProgressBar = (NotificationProgressBar) (findViewById(R.id.progressNotification));
    final Uri data = getIntent().getData();

    mCastMediaUri = Cast.getCastMediaUri(data);

    if (USE_MAP) {
        initOverlays();// w  w  w .j  a  va  2s . c  o m
        // mMapController = ((MapView) findViewById(R.id.map)).getController();
    } else {
        final View mapContainer = findViewById(R.id.pointer_shadow);
        if (mapContainer != null) {
            mapContainer.setVisibility(View.GONE);
        }
    }

    mLoaderManager = getSupportLoaderManager();
    mLoaderManager.initLoader(LOADER_CAST, null, this);
    mLoaderManager.initLoader(LOADER_CAST_MEDIA, null, this);
    findViewById(R.id.home).setOnClickListener(this);
    findViewById(R.id.refresh).setOnClickListener(this);
    mRefresh = (RefreshButton) findViewById(R.id.refresh);
    mRefresh.setOnClickListener(this);

    final Gallery castMediaView = (Gallery) findViewById(R.id.cast_media);

    mCastMedia = new CastMediaAdapter(this);

    castMediaView.setEmptyView(findViewById(R.id.progressNotification));
    castMediaView.setAdapter(new ImageLoaderAdapter(this, mCastMedia, ImageCache.getInstance(this),
            new int[] { R.id.media_thumbnail }, 480, 360, ImageLoaderAdapter.UNIT_DIP));

    castMediaView.setOnItemClickListener(this);

    castMediaView.setEnabled(true);

    final String action = getIntent().getAction();
    if (Intent.ACTION_DELETE.equals(action)) {
        showDialog(DIALOG_CONFIRM_DELETE);
    }
}

From source file:net.evendanan.android.hagarfingerpainting.HagarFingerpaintingActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_NEW_PAPER:
        final Dialog newPaper = new Dialog(this);
        newPaper.setTitle(R.string.new_paper_dialog_title);
        newPaper.setContentView(R.layout.new_paper_dialog);
        newPaper.setCancelable(true);//from ww w . j  a v  a2  s.c  o m
        final EditText painterName = (EditText) newPaper.findViewById(R.id.painter_name_input_text);
        Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/schoolbell.ttf");
        painterName.setTypeface(tf);

        final Gallery colors = (Gallery) newPaper.findViewById(R.id.colors_list);
        colors.setAdapter(new PaperColorListAdapter(getApplicationContext()));
        colors.setOnItemSelectedListener(new OnItemSelectedListener() {
            private View mSelectedItem = null;

            @Override
            public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) {
                if (mSelectedItem != null)
                    mSelectedItem.setBackgroundDrawable(null);

                mSelectedItem = v;
                if (mSelectedItem != null)
                    mSelectedItem.setBackgroundResource(R.drawable.selected_color_background);
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {
                if (mSelectedItem != null)
                    mSelectedItem.setBackgroundDrawable(null);
            }
        });

        colors.setSelection(2);

        View createButton = newPaper.findViewById(R.id.new_paper_create_button);
        createButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
                Editor e = sp.edit();

                final CharSequence painterNameFromUI = painterName.getText().toString();
                final String newPainterName = TextUtils.isEmpty(painterNameFromUI)
                        ? getString(R.string.settings_key_painter_name_default_value)
                        : painterNameFromUI.toString();
                e.putString(getString(R.string.settings_key_painter_name), newPainterName);

                e.commit();

                PaperBackground paper = (PaperBackground) colors.getSelectedItem();

                newPaper.dismiss();

                createNewPaper(paper);
            }
        });
        View cancelButton = newPaper.findViewById(R.id.new_paper_cancel_button);
        cancelButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                newPaper.dismiss();
                if (!mPaperCreated)
                    HagarFingerpaintingActivity.this.finish();
            }
        });
        newPaper.setOnCancelListener(new OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                if (!mPaperCreated)
                    HagarFingerpaintingActivity.this.finish();
            }
        });

        return newPaper;
    default:
        return super.onCreateDialog(id);
    }
}

From source file:edu.mit.mobile.android.locast.ver2.browser.BrowserHome.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mImageCache = ImageCache.getInstance(this);

    setContentView(R.layout.browser_main);

    if (Constants.USE_APPUPDATE_CHECKER) {
        mAppUpdateChecker = new AppUpdateChecker(this, getString(R.string.app_update_url),
                new AppUpdateChecker.OnUpdateDialog(this, getString(R.string.app_name)));
        mAppUpdateChecker.checkForUpdates();
    }/*from   w  w  w . java2  s.  co m*/

    final Gallery casts = (Gallery) findViewById(R.id.casts);

    final String[] from = { Cast._TITLE, Cast._AUTHOR, Cast._THUMBNAIL_URI };
    final int[] to = { R.id.cast_title, R.id.author, R.id.media_thumbnail };

    mAdapter = new CastCursorAdapter(this, null, R.layout.cast_large_thumbnail_item, from, to);
    casts.setAdapter(new ImageLoaderAdapter(this, mAdapter, mImageCache, new int[] { R.id.media_thumbnail },
            320, 200, ImageLoaderAdapter.UNIT_DIP));
    casts.setOnItemClickListener(this);
    casts.setEmptyView(findViewById(android.R.id.empty));
    final LoaderManager lm = getSupportLoaderManager();
    lm.initLoader(LOADER_FEATURED_CASTS, null, this);

    mRefresh = (RefreshButton) findViewById(R.id.refresh);
    mRefresh.setOnClickListener(this);
    findViewById(R.id.itineraries).setOnClickListener(this);
    findViewById(R.id.events).setOnClickListener(this);
    findViewById(R.id.nearby).setOnClickListener(this);
    findViewById(R.id.favorites).setOnClickListener(this);

    shouldRefresh = !checkFirstTime();
}

From source file:com.hybris.mobile.activity.AbstractProductDetailActivity.java

/**
 * Refresh the UI with data from the product
 */// w  ww  . j a  va 2s .co m
public void updateUI() {

    // Title
    this.setTitle(mProduct.getName());

    // Images
    if (mProduct.getGalleryImageURLs() != null) {
        GalleryAdapter adapter = new GalleryAdapter(this, mProduct.getGalleryImageURLs());
        Gallery gallery = (Gallery) findViewById(R.id.galleryImages);
        gallery.setAdapter(adapter);

        // Set the onClick listener for the gallery
        gallery.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long arg3) {
                viewImage(position);

            }
        });
    }

    // Reviews
    TextView reviewTextView = (TextView) findViewById(R.id.textViewReviews);
    reviewTextView.setText(this.getResources().getString(R.string.show_reviews, mProduct.getReviews().size()));

    // Rating (stars)
    RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBarRating);
    if (mProduct.getAverageRating() != null) {
        ratingBar.setRating(mProduct.getAverageRating().floatValue());
    }

    // Promotions
    TextView promotionsTextView = (TextView) findViewById(R.id.textViewPromotion);
    if (mProduct.getPotentialPromotions().size() == 0) {
        promotionsTextView.setVisibility(View.GONE);
    } else {
        if (mProduct.getPotentialPromotions() != null && !mProduct.getPotentialPromotions().isEmpty()) {
            promotionsTextView.setText(
                    Html.fromHtml(Product.generatePromotionString(mProduct.getPotentialPromotions().get(0))));
            StringUtil.removeUnderlines((Spannable) promotionsTextView.getText());
        }

    }

    TextView priceTextView = (TextView) findViewById(R.id.textViewPrice);
    priceTextView.setText(mProduct.getPrice().getFormattedValue());

    // Description
    TextView descriptionTextView = (TextView) findViewById(R.id.textViewDescription);
    descriptionTextView.setText(mProduct.getDescription());

    // Stock level
    TextView stockLevelTextView = (TextView) findViewById(R.id.textViewStockLevel);
    String stockLevelText = mProduct.getStockLevelText(Hybris.getAppContext());
    if (mProduct.getStock().getStockLevel() > 0) {
        stockLevelText = mProduct.getStock().getStockLevel() + " "
                + mProduct.getStockLevelText(Hybris.getAppContext()).toLowerCase();
    }
    stockLevelTextView.setText(stockLevelText);

    // Disable / Enable the add to cart button
    Button addToCartButton = (Button) findViewById(R.id.buttonAddToCart);

    Button quantityButton = (Button) findViewById(R.id.quantityButton);
    quantityButton.setText(getString(R.string.quantity_button, quantityToAddToCart));

    try {

        if (mProduct.getStock().getStockLevelStatus() != null
                && StringUtils.equalsIgnoreCase(mProduct.getStock().getStockLevelStatus().getCode(),
                        ProductStockLevelStatus.CODE_OUT_OF_STOCK)) {
            addToCartButton.setEnabled(false);
            quantityButton.setEnabled(false);
            quantityButton.setText(R.string.quantity);
        } else {
            addToCartButton.setEnabled(true);
            quantityButton.setEnabled(true);
        }
    } catch (Exception e) {
    }

    invalidateOptionsMenu();
}