List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:com.pertamina.tbbm.rewulu.ecodriving.ContentsActivity.java
private void initPanel() { // TODO Auto-generated method stub imgs = new ArrayList<>(); panel.removeAllViews();// w w w . j ava 2 s. c o m for (int w = 0; w < pageSize; w++) { ImageView img = new ImageView(getApplicationContext()); img.setLayoutParams(params); if (0 == w) img.setImageResource(R.drawable.panel_indicator_full); else img.setImageResource(R.drawable.panel_indicator); img.setVisibility(View.VISIBLE); img.setOnClickListener(this); panel.addView(img); imgs.add(img); } }
From source file:edu.rowan.app.carousel.CarouselFeature.java
public CarouselFeature(Context context) { // default feature with simple default image this.context = context; imageURL = null;/* w ww . j a va2s.c o m*/ url = null; carouselView = new RelativeLayout(context); imageView = new ImageView(context); imageView.setImageResource(R.drawable.carousel_placeholder); carouselView.setTag(DEFAULT_FEATURE_TAG); carouselView.addView(imageView); }
From source file:com.example.linhdq.test.documents.creation.visualisation.LayoutQuestionDialog.java
@NonNull @Override/*w w w .ja v a 2s.c om*/ public Dialog onCreateDialog(Bundle savedInstanceState) { final Context context = getContext(); mLayout = null; Pair<String, String> language = PreferencesUtils.getOCRLanguage(context); final InstallStatus installStatus = OcrLanguageDataStore.isLanguageInstalled(language.first, context); if (!installStatus.isInstalled()) { final String defaultLanguage = context.getString(R.string.default_ocr_language); final String defaultLanguageDisplay = context.getString(R.string.default_ocr_display_language); language = Pair.create(defaultLanguage, defaultLanguageDisplay); } mLanguage = language.first; AlertDialog.Builder builder; builder = new AlertDialog.Builder(context); builder.setCancelable(false); View layout = View.inflate(context, R.layout.dialog_layout_question, null); builder.setView(layout); final ViewFlipper titleViewFlipper = (ViewFlipper) layout.findViewById(R.id.layout_title); final ImageView columnLayout = (ImageView) layout.findViewById(R.id.column_layout); final ImageView pageLayout = (ImageView) layout.findViewById(R.id.page_layout); final ImageSwitcher fairy = (ImageSwitcher) layout.findViewById(R.id.fairy_layout); fairy.setFactory(new ViewSwitcher.ViewFactory() { public View makeView() { return new ImageView(context); } }); fairy.setImageResource(R.drawable.fairy_looks_center); fairy.setInAnimation(context, android.R.anim.fade_in); fairy.setOutAnimation(context, android.R.anim.fade_out); final int color = context.getResources().getColor(R.color.progress_color); final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(color, PorterDuff.Mode.LIGHTEN); columnLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mLayout != LayoutKind.COMPLEX) { fairy.setImageResource(R.drawable.fairy_looks_left); titleViewFlipper.setDisplayedChild(2); columnLayout.setColorFilter(colorFilter); pageLayout.clearColorFilter(); mLayout = LayoutKind.COMPLEX; } } }); pageLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mLayout != LayoutKind.SIMPLE) { mLayout = LayoutKind.SIMPLE; titleViewFlipper.setDisplayedChild(1); fairy.setImageResource(R.drawable.fairy_looks_right); pageLayout.setColorFilter(colorFilter); columnLayout.clearColorFilter(); } } }); final Spinner langButton = (Spinner) layout.findViewById(R.id.button_language); List<OcrLanguage> installedLanguages = OcrLanguageDataStore.getInstalledOCRLanguages(context); // actual values uses by tesseract final ArrayAdapter<OcrLanguage> adapter = new ArrayAdapter<>(context, R.layout.item_spinner_language, installedLanguages); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); langButton.setAdapter(adapter); for (int i = 0; i < installedLanguages.size(); i++) { OcrLanguage lang = installedLanguages.get(i); if (lang.getValue().equals(language.first)) { langButton.setSelection(i, false); break; } } langButton.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { final OcrLanguage item = adapter.getItem(position); mLanguage = item.getValue(); PreferencesUtils.saveOCRLanguage(context, item); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); builder.setPositiveButton(R.string.start_scan, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (mLayout == null) { mLayout = LayoutKind.SIMPLE; } LayoutChoseListener listener = (LayoutChoseListener) getActivity(); listener.onLayoutChosen(mLayout, mLanguage); dialog.dismiss(); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { getActivity().finish(); dialog.dismiss(); } }); return builder.create(); }
From source file:hongik.android.project.best.StoreActivity.java
public void drawPage() throws Exception { String query = "func=storereview" + "&license=" + license; DBConnector conn = new DBConnector(query); conn.start();//from w ww . ja va 2s. co m conn.join(); JSONObject jsonResult = conn.getResult(); boolean result = jsonResult.getBoolean("result"); if (!result) return; final JSONObject store = jsonResult.getJSONArray("store").getJSONObject(0); JSONArray menu = null; if (!jsonResult.isNull("menu")) menu = jsonResult.getJSONArray("menu"); JSONArray review = null; if (!jsonResult.isNull("review")) review = jsonResult.getJSONArray("review"); //Draw Store Information Lat = Double.parseDouble(store.getString("LAT")); Lng = Double.parseDouble(store.getString("LNG")); sname = store.getString("SNAME"); ((TextViewPlus) findViewById(R.id.store_storename)).setText(sname); ((TextViewPlus) findViewById(R.id.store_address)).setText(store.getString("ADDR")); ImageLoader imgLoader = new ImageLoader(store.getString("IMG")); imgLoader.start(); try { imgLoader.join(); Bitmap storeImg = imgLoader.getBitmap(); ((ImageView) findViewById(R.id.store_image)).setImageBitmap(storeImg); } catch (InterruptedException e) { Toast.makeText(this, "Can not bring " + license + "store's image", Toast.LENGTH_SHORT).show(); Log.e("StoreInfo", "Can not bring " + license + "store's image"); } //Draw Menu Table if (menu != null) { TableRow motive = (TableRow) menuTable.getChildAt(1); for (int i = 0; i < menu.length(); i++) { JSONObject json = menu.getJSONObject(i); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[3]; final String[] elements = new String[2]; elements[0] = json.getString("ITEM#"); elements[1] = json.getString("PRICE"); imgLoader = new ImageLoader(json.getString("IMG")); imgLoader.start(); imgLoader.join(); ImageView img = new ImageView(this); Bitmap bitmap = imgLoader.getBitmap(); img.setImageBitmap(bitmap); img.setLayoutParams(motive.getChildAt(0).getLayoutParams()); img.setScaleType(ImageView.ScaleType.FIT_XY); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent storeIntent = new Intent(originActivity, MenuActivity.class); storeIntent.putExtra("LICENSE", license); storeIntent.putExtra("MENU", elements[0]); startActivity(storeIntent); } }); tbRow.addView(img); for (int j = 0; j < 2; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j + 1).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent storeIntent = new Intent(originActivity, MenuActivity.class); storeIntent.putExtra("LICENSE", license); storeIntent.putExtra("MENU", elements[0]); startActivity(storeIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } menuTable.addView(tbRow); } } menuTable.removeViewAt(1); //Draw Review Table if (review != null) { TableRow motive = (TableRow) reviewTable.getChildAt(1); int rowCnt = 5; if (review.length() < 5) rowCnt = review.length(); for (int i = 0; i < rowCnt; i++) { JSONObject json = review.getJSONObject(i); final String[] elements = new String[4]; elements[0] = Double.parseDouble(json.getString("GRADE")) + ""; elements[1] = json.getString("NOTE"); elements[2] = json.getString("CID#"); elements[3] = json.getString("DAY"); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[4]; if (elements[1].length() > 14) elements[1] = elements[1].substring(0, 14) + "..."; for (int j = 0; j < 4; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class); reviewIntent.putExtra("ACCESS", "STORE"); reviewIntent.putExtra("CID", elements[2]); reviewIntent.putExtra("LICENSE", license); Log.i("StoreReview", "StartActivity"); startActivity(reviewIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } reviewTable.addView(tbRow); } } reviewTable.removeViewAt(1); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.store_map); mapFragment.getMapAsync(this); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.VoiceObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.play); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); frame.addView(imageView);/*w ww . ja v a 2 s . c om*/ }
From source file:kr.wdream.ui.Components.PagerSlidingTabStrip.java
private void addIconTab(final int position, int resId) { ImageView tab = new ImageView(getContext()) { @Override/* w w w .j av a 2s. c om*/ protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (pager.getAdapter() instanceof IconTabProvider) { ((IconTabProvider) pager.getAdapter()).customOnDraw(canvas, position); } } }; tab.setFocusable(true); tab.setImageResource(resId); tab.setScaleType(ImageView.ScaleType.CENTER); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tabsContainer.addView(tab); tab.setSelected(position == currentPosition); }
From source file:com.gudong.appkit.ui.fragment.ColorChooseDialog.java
private View getColorItemView(final Context context, int position, boolean isSelect) { int color = mColors[position]; int widthImageCheckView = Utils.convertDensityPix(context, 24); int widthColorView = Utils.convertDensityPix(context, 56); int widthMargin = Utils.convertDensityPix(context, 4); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.ic_check); FrameLayout.LayoutParams ivParams = new FrameLayout.LayoutParams(widthImageCheckView, widthImageCheckView); ivParams.gravity = Gravity.CENTER;//from w ww .jav a2 s . c o m imageView.setLayoutParams(ivParams); imageView.setVisibility(isSelect ? View.VISIBLE : View.INVISIBLE); FrameLayout frameLayout = new FrameLayout(context); GridLayout.LayoutParams params = new GridLayout.LayoutParams( new FrameLayout.LayoutParams(widthColorView, widthColorView)); params.setGravity(Gravity.CENTER); params.setMargins(widthMargin, widthMargin, widthMargin, widthMargin); frameLayout.setLayoutParams(params); setBackgroundSelector(frameLayout, color); frameLayout.addView(imageView); frameLayout.setOnClickListener(this); frameLayout.setTag(position); return frameLayout; }
From source file:cn.qbcbyb.library.view.PagerTabStrip.java
private void addIconTab(final int position) { ImageView tab = new ImageView(getContext()); tab.setImageResource(indicatorDrawable); tab.setScaleType(ImageView.ScaleType.CENTER); addTab(position, tab);//from w w w.ja va2 s.c o m }
From source file:com.paginatedgallery.PaginatedGalleryAdapter.java
@Override public Object instantiateItem(View collection, int position) { LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.HORIZONTAL); layout.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenWidth / viewsPerPage)); int size = images.size(); // Log.i(TAG, "Position: "+position + " , Size : "+size); for (int i = 0; i < viewsPerPage; i++) { final int index = position + (position * (viewsPerPage - 1)) + i; Log.i(TAG, "Index: " + index + " , Size : " + size); if (index < size) { View imageView;/*from www. j ava 2 s.c om*/ if (isImageUrl) { imageView = new RemoteImageView(context, (String) images.get(index), errorDrawable, errorDrawable, true); } else { imageView = new ImageView(context); ((ImageView) imageView).setImageDrawable((Drawable) images.get(index)); } // imageView.setTag(index); imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mItemClickListener != null) { mItemClickListener.onItemClick(v, index); } } }); imageView.setLayoutParams(new LayoutParams(screenWidth / viewsPerPage, screenWidth / viewsPerPage)); imageView.setPadding(10, 10, 10, 10); layout.addView(imageView); } } ((ViewPager) collection).addView(layout); return layout; }
From source file:com.chuger.bithdayapp.view.auth.AuthDialog.java
private void createCrossImage() { mCrossImage = new ImageView(getContext()); // Dismiss the dialog when user click on the 'x' mCrossImage.setOnClickListener(new View.OnClickListener() { @Override/*from w w w .ja va 2 s . c o m*/ public void onClick(final View v) { mListener.onCancel(); AuthDialog.this.dismiss(); } }); final Drawable crossDrawable = getContext().getResources().getDrawable(R.drawable.close); mCrossImage.setImageDrawable(crossDrawable); /* 'x' should not be visible while webview is loading * make it visible only after webview has fully loaded */ mCrossImage.setVisibility(View.INVISIBLE); }