Example usage for android.widget ImageView ImageView

List of usage examples for android.widget ImageView ImageView

Introduction

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

Prototype

public ImageView(Context context) 

Source Link

Usage

From source file:com.wll.main.widget.AbSlidingPlayView.java

/**
 * ./*  w ww . j  a va 2s . co  m*/
 */
public void creatIndex() {
    // ?
    //      Bitmap bm=BitmapFactory.decodeResource(context.getResources(), R.color.black);
    //      Bitmap bm2=BitmapFactory.decodeResource(context.getResources(), R.color.write);
    //      displayImage=bm;
    //      hideImage=bm2;
    navLinearLayout.removeAllViews();
    mNavLayoutParent.setHorizontalGravity(navHorizontalGravity);
    navLinearLayout.setGravity(Gravity.CENTER);
    navLinearLayout.setVisibility(View.VISIBLE);
    count = mListViews.size();
    navLayoutParams.setMargins(5, 5, 5, 5);
    for (int j = 0; j < count; j++) {
        ImageView imageView = new ImageView(context);
        imageView.setLayoutParams(navLayoutParams);
        if (j == 0) {
            imageView.setImageBitmap(displayImage);
        } else {
            imageView.setImageBitmap(hideImage);
        }
        navLinearLayout.addView(imageView, j);
    }
}

From source file:it.chefacile.app.MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mContext = this;
    chefacileDb = new DatabaseHelper(this);
    // FilterButton = (ImageButton) findViewById(R.id.buttonfilter);
    TutorialButton = (ImageButton) findViewById(R.id.button);
    //  AddButton = (ImageButton) findViewById(R.id.button2);
    responseView = (TextView) findViewById(R.id.responseView);
    editText = (EditText) findViewById(R.id.ingredientText);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    //Show = (ImageButton) findViewById(R.id.buttonShow);
    //Show2 = (ImageButton) findViewById(R.id.buttonShow2);
    materialAnimatedSwitch = (MaterialAnimatedSwitch) findViewById(R.id.pin);
    //buttoncuisine = (ImageButton) findViewById(R.id.btn_cuisine);
    //buttondiet = (ImageButton) findViewById(R.id.btn_diet);
    //buttonintol = (ImageButton) findViewById(R.id.btn_intoll);
    //Mostra = (Button) findViewById(R.id.btn_mostra);

    final Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible
    animation.setDuration(1000); // duration - half a second
    animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
    animation.setRepeatCount(5); // Repeat animation infinitely
    animation.setRepeatMode(Animation.REVERSE);

    ImageView icon = new ImageView(this); // Create an icon
    icon.setImageDrawable(getResources().getDrawable(R.drawable.logo));

    final com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton actionButton = new com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton.Builder(
            this).setPosition(
                    com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton.POSITION_RIGHT_CENTER)
                    .setContentView(icon).build();

    SubActionButton.Builder itemBuilder = new SubActionButton.Builder(this);
    // repeat many times:
    ImageView dietIcon = new ImageView(this);
    dietIcon.setImageDrawable(getResources().getDrawable(R.drawable.diet));
    SubActionButton button1 = itemBuilder.setContentView(dietIcon).build();
    button1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showSingleChoiceDialogDiet(v);
        }//from w ww.  j av a2s .c  om
    });

    ImageView intolIcon = new ImageView(this);
    intolIcon.setImageDrawable(getResources().getDrawable(R.drawable.intoll));
    SubActionButton button2 = itemBuilder.setContentView(intolIcon).build();
    button2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showMultiChoiceDialogIntol(v);
        }
    });

    ImageView cuisineIcon = new ImageView(this);
    cuisineIcon.setImageDrawable(getResources().getDrawable(R.drawable.cook12));
    SubActionButton button3 = itemBuilder.setContentView(cuisineIcon).build();
    button3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showMultiChoiceDialogCuisine(v);
        }
    });

    ImageView favouriteIcon = new ImageView(this);
    favouriteIcon.setImageDrawable(getResources().getDrawable(R.drawable.favorite));
    SubActionButton button4 = itemBuilder.setContentView(favouriteIcon).build();
    button4.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showSimpleListDialogFav(v);
        }
    });

    ImageView wandIcon = new ImageView(this);
    wandIcon.setImageDrawable(getResources().getDrawable(R.drawable.wand));
    SubActionButton button5 = itemBuilder.setContentView(wandIcon).build();
    button5.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            sugg = getSuggestion();
            suggOccurrences = getCount();
            showSimpleListDialogSuggestions(v);
        }
    });

    final FloatingActionButton actionABC = (FloatingActionButton) findViewById(R.id.action_abc);

    actionABC.bringToFront();
    actionABC.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (ingredients.length() < 2) {
                Snackbar.make(responseView, "Insert at least one ingredient", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            } else {
                new RetrieveFeedTask().execute();
            }
        }

        // Snackbar.make(view, "Non disponibile, mangia l'aria", Snackbar.LENGTH_LONG)
        //         .setAction("Action", null).show();

    });

    FloatingActionMenu actionMenu = new FloatingActionMenu.Builder(this).setStartAngle(90).setEndAngle(270)
            .addSubActionView(button1).addSubActionView(button2).addSubActionView(button3)
            .addSubActionView(button4).addSubActionView(button5).attachTo(actionButton).build();

    startDatabase(chefacileDb);

    for (int j = 0; j < cuisineItems.length; j++) {
        cuisineItems[j] = cuisineItems[j].substring(0, 1).toUpperCase() + cuisineItems[j].substring(1);
    }
    Arrays.sort(cuisineItems);

    for (int i = 0; i < 24; i++) {
        cuisineBool[i] = false;
    }

    Arrays.sort(intolItems);

    for (int i = 0; i < 11; i++) {
        intolBool[i] = false;
    }

    mListView = (MaterialListView) findViewById(R.id.material_listview);

    adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);

    TutorialButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, IntroScreenActivity.class));
            overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);

        }
    });

    iv = (ImageView) findViewById(R.id.imageView);
    iv.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            clicks++;
            Log.d("CLICKS", String.valueOf(clicks));
            if (clicks == 15) {
                Log.d("IMAGE SHOWN", "mai vero");
                setBackground(iv);
            }
        }
    });

    materialAnimatedSwitch.setOnCheckedChangeListener(new MaterialAnimatedSwitch.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(boolean isChecked) {
            if (isChecked == true) {
                ranking = 2;
                Toast.makeText(getApplicationContext(), "Minimize missing ingredients", Toast.LENGTH_SHORT)
                        .show();
            } else {
                ranking = 1;
                Toast.makeText(getApplicationContext(), "Maximize used ingredients", Toast.LENGTH_SHORT).show();
            }
            Log.d("Ranking", String.valueOf(ranking));
        }
    });

    final CharSequence[] items = { "Maximize used ingredients", "Minimize missing ingredients" };

    editText.setOnKeyListener(new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_CENTER:
                case KeyEvent.KEYCODE_ENTER:
                    if (!(editText.getText().toString().trim().equals(""))) {

                        String input;
                        String s1 = editText.getText().toString().substring(0, 1).toUpperCase();
                        String s2 = editText.getText().toString().substring(1);
                        input = s1 + s2;

                        Log.d("INPUT: ", input);
                        searchedIngredients.add(input);
                        Log.d("SEARCHED INGR LIST", searchedIngredients.toString());

                        if (!chefacileDb.findIngredientPREF(input)) {
                            if (chefacileDb.findIngredient(input)) {
                                chefacileDb.updateCount(input);
                                mapIngredients = chefacileDb.getDataInMapIngredient();
                                Map<String, Integer> map2;
                                map2 = sortByValue(mapIngredients);
                                Log.d("MAPPACOUNT: ", map2.toString());

                            } else {
                                if (chefacileDb.occursExceeded()) {
                                    //chefacileDb.deleteMinimum(input);
                                    // chefacileDb.insertDataIngredient(input);
                                    mapIngredients = chefacileDb.getDataInMapIngredient();
                                    Map<String, Integer> map3;
                                    map3 = sortByValue(mapIngredients);
                                    Log.d("MAPPAINGREDIENTE: ", map3.toString());

                                } else {
                                    chefacileDb.insertDataIngredient(input);
                                    mapIngredients = chefacileDb.getDataInMapIngredient();
                                    Map<String, Integer> map3;
                                    map3 = sortByValue(mapIngredients);
                                    Log.d("MAPPAINGREDIENTE: ", map3.toString());
                                }
                            }
                        }
                    }

                    if (editText.getText().toString().trim().equals("")) {
                        ingredients += editText.getText().toString().trim() + "";
                        editText.getText().clear();

                    } else {
                        ingredients += editText.getText().toString().replaceAll(" ", "+").trim().toLowerCase()
                                + ",";
                        singleIngredient = editText.getText().toString().trim().toLowerCase();
                        currentIngredient = singleIngredient;
                        new RetrieveIngredientTask().execute();

                        //adapter.add(singleIngredient.substring(0,1).toUpperCase() + singleIngredient.substring(1));
                    }

                    InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

                    in.hideSoftInputFromWindow(editText.getApplicationWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);

                    actionABC.startAnimation(animation);

                    return true;
                default:
                    break;
                }
            }
            return false;
        }
    });

    responseView = (TextView) findViewById(R.id.responseView);
    editText = (EditText) findViewById(R.id.ingredientText);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);

}

From source file:com.example.facebook_volley.Albums_photo.SlidingTabAlbum.java

protected ImageView createDefaultImageView(Context context) {
    ImageView imageView = new ImageView(context);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    imageView.setPadding(padding, padding, padding, padding);

    int width = (int) (getResources().getDisplayMetrics().widthPixels / mViewPager.getAdapter().getCount());
    imageView.setMinimumWidth(width);//from   ww w .  j  a  v  a2  s  .c o m

    return imageView;
}

From source file:com.markupartist.sthlmtraveling.ui.view.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//ww  w . ja  va  2s .  c o  m
 */
protected ImageView createImageTabView(Context context) {
    ImageView v = new ImageView(context);
    v.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    v.setBackgroundResource(outValue.resourceId);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    v.setPadding(padding, padding, padding, padding);

    return v;
}

From source file:com.redwoodsystems.android.apps.LightingListFragment.java

private void setupScenesList() {
    Log.d(TAG, "setupScenesList called");
    ListView listView = (ListView) getActivity().findViewById(android.R.id.list);
    TextView dummy = new TextView(getActivity());
    ImageView dummy2 = new ImageView(getActivity());
    listView.addFooterView(dummy, null, true);
    listView.setFooterDividersEnabled(true);
    listView.addHeaderView(dummy2, null, true);
    listView.setHeaderDividersEnabled(true);
    int[] colors = { 0, 0xFFF47836, 0 }; // Pantone172 for the example
    listView.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
    listView.setDividerHeight(1);//from  ww w  .  j  a  va2  s. c om

    //TODO: set Empty Text inside View
    //setEmptyText("No Scenes found");

    mSceneAdapter = new SceneAdapter(getActivity(), R.layout.scene_item_layout, R.id.sceneText);

    setListAdapter(mSceneAdapter);

    Uri dummyUri = null;
    Bundle params = new Bundle();
    Bundle args = new Bundle();
    args.putParcelable(ARGS_URI, dummyUri);
    args.putParcelable(ARGS_PARAMS, params);

    // Initialize the Loader.
    Log.d(TAG, "calling initLoader..");
    getActivity().getSupportLoaderManager().initLoader(LOADER_SCENES, null, this);

}

From source file:com.huyn.demogroup.relativetop.PagerSlidingTabStrip.java

private void addIconAndTextTab(int position, int resId, String title) {
    LinearLayout tab = new LinearLayout(getContext());
    tab.setGravity(Gravity.CENTER);//from  ww  w.ja  va2s . com

    TextView text = new TextView(getContext());
    text.setText(title);
    text.setTextColor(Color.WHITE);
    text.setGravity(Gravity.CENTER);
    text.setSingleLine();

    ImageView img = new ImageView(getContext());
    img.setImageBitmap(iProvider.getBitmap(resId));

    tab.addView(img);
    tab.addView(text);
    text.setPadding(10, 0, 0, 0);
    text.setTag("TEXT");

    addTab(position, tab);
}

From source file:example.example.com.sportsofficial.presentation.views.ViewTabs.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int, int)}.
 *///from  ww w . ja  v  a  2s .c  o m
protected ImageView createDefaultIconTabView(Context context) {
    ImageView tabIconImageView = new ImageView(context);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        tabIconImageView.setBackgroundResource(outValue.resourceId);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    tabIconImageView.setPadding(padding, padding, padding, padding);

    return tabIconImageView;
}

From source file:br.edu.ifpb.breath.slidingtabs.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int, int)}.
 *//*from  w ww .j  a  v  a2 s.c  o m*/
protected View createDefaultTabView(Context context, int type) {
    if (type == 0) {
        TextView textView = new TextView(context);
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
        textView.setTypeface(Typeface.DEFAULT_BOLD);
        textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));

        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
        textView.setAllCaps(true);

        int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
        textView.setPadding(padding, padding, padding, padding);

        return textView;
    } else {
        ImageView iconView = new ImageView(context);
        int iconSize = (int) (TAB_VIEW_ICON_SIZE_DIPS * getResources().getDisplayMetrics().density);
        int padding = (int) (TAB_VIEW_ICON_PADDING_DIPS * getResources().getDisplayMetrics().density);

        iconView.setLayoutParams(new LinearLayout.LayoutParams(iconSize + padding, iconSize + padding));
        iconView.setScaleType(ImageView.ScaleType.FIT_CENTER);
        iconView.setPadding(padding, padding, padding, padding);

        return iconView;
    }
}

From source file:more.sandbox.views.SlidingTabLayout.java

protected ImageView createDefaultImageTabView(Context context) {
    ImageView iv = new ImageView(context);
    iv.setImageResource(R.drawable.icon_map);
    return iv;//from w w w.  j  a  va 2 s.  c  o  m
}

From source file:info.guardianproject.pixelknot.PixelKnotActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    dump = new File(DUMP);
    if (!dump.exists())
        dump.mkdir();//  ww w. j a v  a  2s.co  m

    d = R.drawable.progress_off_selected;
    d_ = R.drawable.progress_on;

    setContentView(R.layout.pixel_knot_activity);

    ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    scale = Image.getScale(am.getMemoryClass());

    if (Build.VERSION.SDK_INT <= 10)
        getSupportActionBar().hide();
    else
        ((RelativeLayout) findViewById(R.id.pk_header)).setVisibility(View.GONE);

    imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);

    options_holder = (LinearLayout) findViewById(R.id.options_holder);

    action_display = (LinearLayout) findViewById(R.id.action_display);
    action_display_ = (LinearLayout) findViewById(R.id.action_display_);

    progress_holder = (LinearLayout) findViewById(R.id.progress_holder);

    List<Fragment> fragments = new Vector<Fragment>();

    if (getIntent().getData() == null) {
        Fragment cover_image_fragment = Fragment.instantiate(this, CoverImageFragment.class.getName());
        Fragment set_message_fragment = Fragment.instantiate(this, SetMessageFragment.class.getName());
        Fragment share_fragment = Fragment.instantiate(this, ShareFragment.class.getName());

        fragments.add(0, cover_image_fragment);
        fragments.add(1, set_message_fragment);
        fragments.add(2, share_fragment);
    } else {
        Fragment stego_image_fragment = Fragment.instantiate(this, StegoImageFragment.class.getName());
        Bundle args = new Bundle();
        args.putString(Keys.COVER_IMAGE_NAME, IO.pullPathFromUri(this, getIntent().getData()));
        stego_image_fragment.setArguments(args);

        Fragment decrypt_image_fragment = Fragment.instantiate(this, DecryptImageFragment.class.getName());

        fragments.add(0, stego_image_fragment);
        fragments.add(1, decrypt_image_fragment);
    }

    pk_pager = new PKPager(getSupportFragmentManager(), fragments);
    view_pager = (ViewPager) findViewById(R.id.fragment_holder);
    view_pager.setAdapter(pk_pager);
    view_pager.setOnPageChangeListener(this);

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    lp.setMargins(5, 0, 5, 0);

    for (int p = 0; p < fragments.size(); p++) {
        ImageView progress_view = new ImageView(this);
        progress_view.setLayoutParams(lp);
        progress_view.setBackgroundResource(p == 0 ? d_ : d);
        progress_holder.addView(progress_view);
    }

    last_diff = 0;
    activity_root = findViewById(R.id.activity_root);
    activity_root.getViewTreeObserver().addOnGlobalLayoutListener(this);

    last_locale = PreferenceManager.getDefaultSharedPreferences(this).getString(Settings.LANGUAGE, "0");
}