List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:org.lol.reddit.activities.CaptchaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); getSupportActionBar().setTitle(R.string.post_captcha_title); super.onCreate(savedInstanceState); final LoadingView loadingView = new LoadingView(this, R.string.download_waiting, true, true); setContentView(loadingView);/*from w w w . j ava 2s .com*/ final RedditAccount selectedAccount = RedditAccountManager.getInstance(this) .getAccount(getIntent().getStringExtra("username")); final CacheManager cm = CacheManager.getInstance(this); RedditAPI.newCaptcha(cm, new APIResponseHandler.NewCaptchaResponseHandler(this) { @Override protected void onSuccess(final String captchaId) { final URI captchaUrl = Constants.Reddit.getUri("/captcha/" + captchaId); cm.makeRequest(new CacheRequest(captchaUrl, RedditAccountManager.getAnon(), null, Constants.Priority.CAPTCHA, 0, CacheRequest.DownloadType.FORCE, Constants.FileType.CAPTCHA, false, false, true, CaptchaActivity.this) { @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CaptchaActivity.this, t); } @Override protected void onDownloadNecessary() { } @Override protected void onDownloadStarted() { loadingView.setIndeterminate(R.string.download_downloading); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status, url.toString()); General.showResultDialog(CaptchaActivity.this, error); finish(); } @Override protected void onProgress(long bytesRead, long totalBytes) { loadingView.setProgress(R.string.download_downloading, (float) ((double) bytesRead / (double) totalBytes)); } @Override protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, long timestamp, UUID session, boolean fromCache, String mimetype) { final Bitmap image; try { image = BitmapFactory.decodeStream(cacheFile.getInputStream()); } catch (IOException e) { BugReportActivity.handleGlobalError(CaptchaActivity.this, e); return; } General.UI_THREAD_HANDLER.post(new Runnable() { public void run() { final LinearLayout ll = new LinearLayout(CaptchaActivity.this); ll.setOrientation(LinearLayout.VERTICAL); final ImageView captchaImg = new ImageView(CaptchaActivity.this); ll.addView(captchaImg); final LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) captchaImg .getLayoutParams(); layoutParams.setMargins(20, 20, 20, 20); layoutParams.height = General.dpToPixels(context, 100); captchaImg.setScaleType(ImageView.ScaleType.FIT_CENTER); final EditText captchaText = new EditText(CaptchaActivity.this); ll.addView(captchaText); ((LinearLayout.LayoutParams) captchaText.getLayoutParams()).setMargins(20, 0, 20, 20); captchaText.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS); captchaImg.setImageBitmap(image); final Button submitButton = new Button(CaptchaActivity.this); submitButton.setText(R.string.post_captcha_submit_button); ll.addView(submitButton); ((LinearLayout.LayoutParams) submitButton.getLayoutParams()).setMargins(20, 0, 20, 20); ((LinearLayout.LayoutParams) submitButton .getLayoutParams()).gravity = Gravity.RIGHT; ((LinearLayout.LayoutParams) submitButton .getLayoutParams()).width = LinearLayout.LayoutParams.WRAP_CONTENT; submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final Intent result = new Intent(); result.putExtra("captchaId", captchaId); result.putExtra("captchaText", captchaText.getText().toString()); setResult(RESULT_OK, result); finish(); } }); final ScrollView sv = new ScrollView(CaptchaActivity.this); sv.addView(ll); setContentView(sv); } }); } }); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CaptchaActivity.this, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status, null); General.showResultDialog(CaptchaActivity.this, error); finish(); } @Override protected void onFailure(APIFailureType type) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type); General.showResultDialog(CaptchaActivity.this, error); finish(); } }, selectedAccount, this); }
From source file:com.tony.selene.sliding.AbBottomTabView.java
/** * Instantiates a new ab bottom tab view. * * @param context/*from w w w . j av a 2 s. co m*/ * the context * @param attrs * the attrs */ public AbBottomTabView(Context context, AttributeSet attrs) { super(context, attrs); this.context = context; this.setOrientation(LinearLayout.VERTICAL); this.setBackgroundColor(Color.rgb(255, 255, 255)); mTabLayout = new LinearLayout(context); mTabLayout.setOrientation(LinearLayout.HORIZONTAL); mTabLayout.setGravity(Gravity.CENTER); // View? mViewPager = new AbViewPager(context); // ViewPager,setId()id mViewPager.setId(1985); pagerItemList = new ArrayList<Fragment>(); this.addView(mViewPager, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1)); // ? mTabImg = new ImageView(context); mTabImg.setBackgroundColor(tabSlidingColor); this.addView(mTabImg, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, tabSlidingHeight)); this.addView(mTabLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); // Tab? tabItemList = new ArrayList<AbTabItemView>(); tabItemTextList = new ArrayList<String>(); tabItemDrawableList = new ArrayList<Drawable>(); // ?FragmentActivity if (!(this.context instanceof FragmentActivity)) { AbLogUtil.e(AbBottomTabView.class, "AbSlidingTabView?context,FragmentActivity"); } DisplayMetrics mDisplayMetrics = AbAppUtil.getDisplayMetrics(context); mWidth = mDisplayMetrics.widthPixels; FragmentManager mFragmentManager = ((FragmentActivity) this.context).getFragmentManager(); mFragmentPagerAdapter = new AbFragmentPagerAdapter(mFragmentManager, pagerItemList); mViewPager.setAdapter(mFragmentPagerAdapter); mViewPager.setOnPageChangeListener(new MyOnPageChangeListener()); mViewPager.setOffscreenPageLimit(3); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.VideoObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/*from w w w . j ava2 s .c o m*/ byte[] raw = obj.getRaw(); if (raw == null) { Pair<JSONObject, byte[]> p = splitRaw(content); content = p.first; raw = p.second; } LinearLayout inner = new LinearLayout(context); inner.setLayoutParams(CommonLayouts.FULL_WIDTH); inner.setOrientation(LinearLayout.HORIZONTAL); frame.addView(inner); ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); BitmapFactory bf = new BitmapFactory(); imageView.setImageBitmap(bf.decodeByteArray(raw, 0, raw.length)); inner.addView(imageView); ImageView iconView = new ImageView(context); iconView.setImageResource(R.drawable.play); iconView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); inner.addView(iconView); }
From source file:com.ryan.ryanreader.activities.CaptchaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); getSupportActionBar().setTitle(R.string.post_captcha_title); super.onCreate(savedInstanceState); final LoadingView loadingView = new LoadingView(this, R.string.download_waiting, true, true); setContentView(loadingView);//from w w w . j av a2s. c o m final RedditAccount selectedAccount = RedditAccountManager.getInstance(this) .getAccount(getIntent().getStringExtra("username")); final CacheManager cm = CacheManager.getInstance(this); RedditAPI.newCaptcha(cm, new APIResponseHandler.NewCaptchaResponseHandler(this) { @Override protected void onSuccess(final String captchaId) { final URI captchaUrl = Constants.Reddit.getUri("/captcha/" + captchaId); cm.makeRequest(new CacheRequest(captchaUrl, RedditAccountManager.getAnon(), null, Constants.Priority.CAPTCHA, 0, CacheRequest.DownloadType.FORCE, Constants.FileType.CAPTCHA, false, false, true, CaptchaActivity.this) { @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CaptchaActivity.this, t); } @Override protected void onDownloadNecessary() { } @Override protected void onDownloadStarted() { loadingView.setIndeterminate(R.string.download_downloading); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status); General.showResultDialog(CaptchaActivity.this, error); finish(); } @Override protected void onProgress(long bytesRead, long totalBytes) { loadingView.setProgress(R.string.download_downloading, (float) ((double) bytesRead / (double) totalBytes)); } @Override protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, long timestamp, UUID session, boolean fromCache, String mimetype) { final Bitmap image; try { image = BitmapFactory.decodeStream(cacheFile.getInputStream()); } catch (IOException e) { BugReportActivity.handleGlobalError(CaptchaActivity.this, e); return; } new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { final LinearLayout ll = new LinearLayout(CaptchaActivity.this); ll.setOrientation(LinearLayout.VERTICAL); final ImageView captchaImg = new ImageView(CaptchaActivity.this); ll.addView(captchaImg); final LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) captchaImg .getLayoutParams(); layoutParams.setMargins(20, 20, 20, 20); layoutParams.height = General.dpToPixels(context, 100); captchaImg.setScaleType(ImageView.ScaleType.FIT_CENTER); final EditText captchaText = new EditText(CaptchaActivity.this); ll.addView(captchaText); ((LinearLayout.LayoutParams) captchaText.getLayoutParams()).setMargins(20, 0, 20, 20); captchaText.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS); captchaImg.setImageBitmap(image); final Button submitButton = new Button(CaptchaActivity.this); submitButton.setText(R.string.post_captcha_submit_button); ll.addView(submitButton); ((LinearLayout.LayoutParams) submitButton.getLayoutParams()).setMargins(20, 0, 20, 20); ((LinearLayout.LayoutParams) submitButton .getLayoutParams()).gravity = Gravity.RIGHT; ((LinearLayout.LayoutParams) submitButton .getLayoutParams()).width = LinearLayout.LayoutParams.WRAP_CONTENT; submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final Intent result = new Intent(); result.putExtra("captchaId", captchaId); result.putExtra("captchaText", captchaText.getText().toString()); setResult(RESULT_OK, result); finish(); } }); final ScrollView sv = new ScrollView(CaptchaActivity.this); sv.addView(ll); setContentView(sv); } }); } }); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CaptchaActivity.this, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status); General.showResultDialog(CaptchaActivity.this, error); finish(); } @Override protected void onFailure(APIFailureType type) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type); General.showResultDialog(CaptchaActivity.this, error); finish(); } }, selectedAccount, this); }
From source file:ca.cmput301f13t03.adventure_datetime.view.FragmentView.java
public void setUpView() { if (_fragment == null) return;//from w w w.j a v a 2s.c o m /** Layout items **/ _filmLayout = (LinearLayout) _rootView.findViewById(R.id.filmstrip); _filmstrip = (HorizontalScrollView) _rootView.findViewById(R.id.filmstrip_wrapper); _choices = (Button) _rootView.findViewById(R.id.choices); _content = (TextView) _rootView.findViewById(R.id.content); if (_fragment.getStoryMedia() == null) _fragment.setStoryMedia(new ArrayList<Image>()); /* Run on UI Thread for server stuff */ getActivity().runOnUiThread(new Runnable() { @Override public void run() { /** Programmatically set filmstrip height **/ if (_fragment.getStoryMedia().size() > 0) _filmstrip.getLayoutParams().height = FILM_STRIP_SIZE; else _filmstrip.getLayoutParams().height = 0; _content.setText(_fragment.getStoryText()); _filmLayout.removeAllViews(); // 1) Create new ImageView and add to the LinearLayout // 2) Set appropriate Layout Params to ImageView // 3) Give onClickListener for going to fullscreen LinearLayout.LayoutParams lp; //for (int i = 0; i < _fragment.getStoryMedia().size(); i++) { for (int i = 0; i < _fragment.getStoryMedia().size(); i++) { ImageView li = new ImageView(getActivity()); li.setScaleType(ScaleType.CENTER_INSIDE); li.setImageBitmap(_fragment.getStoryMedia().get(i).decodeBitmap()); _filmLayout.addView(li); lp = (LinearLayout.LayoutParams) li.getLayoutParams(); lp.setMargins(10, 10, 10, 10); lp.width = FILM_STRIP_SIZE; lp.height = FILM_STRIP_SIZE; lp.gravity = Gravity.CENTER_VERTICAL; li.setLayoutParams(lp); li.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), FullScreen_Image.class); intent.putExtra(FullScreen_Image.TAG_AUTHOR, false); startActivity(intent); } }); } if (_fragment.getChoices().size() > 0) { /** Choices **/ final List<String> choices = new ArrayList<String>(); for (Choice choice : _fragment.getChoices()) choices.add(choice.getText()); choices.add("I'm feeling lucky."); _choices.setText("Actions"); _choices.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(v.getContext()).setTitle("Actions").setCancelable(true) .setItems(choices.toArray(new String[choices.size()]), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { /** You feeling lucky, punk? **/ if (which == _fragment.getChoices().size()) which = (int) (Math.random() * _fragment.getChoices().size()); Choice choice = _fragment.getChoices().get(which); Toast.makeText(FragmentView.this.getActivity(), choice.getText(), Toast.LENGTH_LONG).show(); Locator.getUserController().MakeChoice(choice); } }) .create().show(); } }); } else { /** End of story **/ Locator.getUserController().deleteBookmark(); _choices.setText("The End"); _choices.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new AlertDialog.Builder(v.getContext()).setTitle("La Fin").setCancelable(true) .setPositiveButton("Play Again", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Locator.getUserController().StartStory(_fragment.getStoryID()); } }) .setNegativeButton("Change Adventures", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (!_isEditing) getActivity().onBackPressed(); } }).create().show(); } }); } } }); }
From source file:com.aprz.easy_iosched.ui.widget.CustomRatingBar.java
/** * Creates ({@link ImageView}s) used to submit a rating using unfilled drawables and adds them to * the layout.//from w w w. j a v a2 s .co m */ private void createRatingViews() { for (int i = 0; i < mMaxRating; i++) { ImageView imageView = new ImageView(getContext()); imageView.setLayoutParams( new android.view.ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); int tagValue = i + 1; imageView.setTag(tagValue); imageView.setContentDescription(getContext().getString(R.string.feedback_rating_value, tagValue)); imageView.setImageDrawable(mUnfilledDrawable); imageView.setOnClickListener(this); addView(imageView); } }
From source file:com.wlzndjk.poker.widget.MyHScrollView.java
private void addImageTab(final int position, String title) { ImageView tab = new ImageView(getContext()); tab.setImageResource(tabDatas.get(position)); tab.setScaleType(ImageView.ScaleType.FIT_XY); addTab(position, tab);//from www . j ava 2 s .co m }
From source file:com.umeng.common.ui.emoji.EmojiBorad.java
/** * ?</br>//from w w w. j a v a 2 s. c o m * * @return */ private ImageView createIndicator() { ImageView imageView = new ImageView(getContext()); LayoutParams params = new LayoutParams(30, 30); params.gravity = Gravity.CENTER; imageView.setLayoutParams(params); imageView.setImageDrawable(ColorQueque.getDrawable(mNormalIcon)); imageView.setPadding(0, 0, 10, 0); return imageView; }
From source file:org.quantumbadger.redreader.activities.CaptchaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); getSupportActionBar().setTitle(R.string.post_captcha_title); super.onCreate(savedInstanceState); final LoadingView loadingView = new LoadingView(this, R.string.download_waiting, true, true); setContentView(loadingView);/*from w w w .j av a2s.c om*/ final RedditAccount selectedAccount = RedditAccountManager.getInstance(this) .getAccount(getIntent().getStringExtra("username")); final CacheManager cm = CacheManager.getInstance(this); RedditAPI.newCaptcha(cm, new APIResponseHandler.NewCaptchaResponseHandler(this) { @Override protected void onSuccess(final String captchaId) { final URI captchaUrl = Constants.Reddit.getUri("/captcha/" + captchaId); cm.makeRequest(new CacheRequest(captchaUrl, RedditAccountManager.getAnon(), null, Constants.Priority.CAPTCHA, 0, CacheRequest.DownloadType.FORCE, Constants.FileType.CAPTCHA, false, false, true, CaptchaActivity.this) { @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CaptchaActivity.this, t); } @Override protected void onDownloadNecessary() { } @Override protected void onDownloadStarted() { loadingView.setIndeterminate(R.string.download_downloading); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status, url.toString()); General.showResultDialog(CaptchaActivity.this, error); finish(); } @Override protected void onProgress(long bytesRead, long totalBytes) { loadingView.setProgress(R.string.download_downloading, (float) ((double) bytesRead / (double) totalBytes)); } @Override protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, long timestamp, UUID session, boolean fromCache, String mimetype) { final Bitmap image; try { image = BitmapFactory.decodeStream(cacheFile.getInputStream()); } catch (IOException e) { BugReportActivity.handleGlobalError(CaptchaActivity.this, e); return; } new Handler(Looper.getMainLooper()).post(new Runnable() { public void run() { final LinearLayout ll = new LinearLayout(CaptchaActivity.this); ll.setOrientation(LinearLayout.VERTICAL); final ImageView captchaImg = new ImageView(CaptchaActivity.this); ll.addView(captchaImg); final LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) captchaImg .getLayoutParams(); layoutParams.setMargins(20, 20, 20, 20); layoutParams.height = General.dpToPixels(context, 100); captchaImg.setScaleType(ImageView.ScaleType.FIT_CENTER); final EditText captchaText = new EditText(CaptchaActivity.this); ll.addView(captchaText); ((LinearLayout.LayoutParams) captchaText.getLayoutParams()).setMargins(20, 0, 20, 20); captchaText.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS); captchaImg.setImageBitmap(image); final Button submitButton = new Button(CaptchaActivity.this); submitButton.setText(R.string.post_captcha_submit_button); ll.addView(submitButton); ((LinearLayout.LayoutParams) submitButton.getLayoutParams()).setMargins(20, 0, 20, 20); ((LinearLayout.LayoutParams) submitButton .getLayoutParams()).gravity = Gravity.RIGHT; ((LinearLayout.LayoutParams) submitButton .getLayoutParams()).width = LinearLayout.LayoutParams.WRAP_CONTENT; submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { final Intent result = new Intent(); result.putExtra("captchaId", captchaId); result.putExtra("captchaText", captchaText.getText().toString()); setResult(RESULT_OK, result); finish(); } }); final ScrollView sv = new ScrollView(CaptchaActivity.this); sv.addView(ll); setContentView(sv); } }); } }); } @Override protected void onCallbackException(Throwable t) { BugReportActivity.handleGlobalError(CaptchaActivity.this, t); } @Override protected void onFailure(RequestFailureType type, Throwable t, StatusLine status, String readableMessage) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status, null); General.showResultDialog(CaptchaActivity.this, error); finish(); } @Override protected void onFailure(APIFailureType type) { final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type); General.showResultDialog(CaptchaActivity.this, error); finish(); } }, selectedAccount, this); }
From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java
/** * Drop money from the top of the layout to the bottom simulating that a * coin or bill is inserted in the moneybox. * /*from w w w .j a va 2s.c om*/ * @param leftMargin * Left side of the coin/bill * @param width * Width of the image to slide down * @param m * Movement with the value of the money to drop */ protected void dropMoney(int leftMargin, int width, Movement m) { ImageView money; AnimationSet moneyDrop; RelativeLayout layout; RelativeLayout.LayoutParams lpParams; Rect r; Activity parent; CurrencyValueDef curr; parent = getActivity(); curr = CurrencyManager.getCurrencyDef(Math.abs(m.getAmount())); r = curr.getDrawable().getBounds(); money = new ImageView(parent); money.setVisibility(View.INVISIBLE); money.setImageDrawable(curr.getDrawable().getConstantState().newDrawable()); money.setTag(curr); money.setId((int) m.getIdMovement()); layout = findLayout(); lpParams = new RelativeLayout.LayoutParams(r.width(), r.height()); lpParams.leftMargin = leftMargin; lpParams.rightMargin = layout.getWidth() - (leftMargin + width); lpParams.topMargin = 0; lpParams.bottomMargin = r.height(); layout.addView(money, lpParams); moneyDrop = createDropAnimation(money, layout, curr); money.setVisibility(View.VISIBLE); SoundsManager.playMoneySound(curr.getType()); VibratorManager.vibrateMoneyDrop(curr.getType()); money.startAnimation(moneyDrop); }