List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:com.app.jdy.adapter.ImagePagerAdapter.java
@Override public View getView(int position, View view, ViewGroup container) { ViewHolder holder;// ww w .ja v a 2s . c o m if (view == null) { holder = new ViewHolder(); view = holder.imageView = new ImageView(context); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } ImagePosition = position; holder.imageView.setScaleType(ImageView.ScaleType.FIT_XY); holder.imageView.setImageBitmap(imageIdList.get(getPosition(position))); holder.imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.i("debug==========position", String.valueOf(getPosition(ImagePosition))); if (getPosition(ImagePosition) == 1) { Intent intent = new Intent(context, PictureActivity.class); Bundle bundle = new Bundle(); intent.putExtra("title", ""); intent.putExtra("url", URLs.HONGBAO_INTRODUCE); intent.putExtras(bundle); context.startActivity(intent); } else if (getPosition(ImagePosition) == 0) { Intent intent = new Intent(context, PictureActivity.class); intent.putExtra("title", "???"); Bundle bundle = new Bundle(); intent.putExtra("url", URLs.SHANGXIAN_INTRODUCE); context.startActivity(intent); } } }); return view; }
From source file:com.android.fastlibrary.ui.activity.FastWelcomeActivity.java
@Override protected void initData() { ArrayList<View> views = new ArrayList<View>(); int[] images = getWelcomeImages(); indicators = new ImageView[images.length]; for (int i = 0; i < images.length; i++) { // /*w w w . j av a 2 s . com*/ ImageView imageView = new ImageView(context); imageView.setBackgroundResource(images[i]); views.add(imageView); // indicators[i] = new ImageView(context); indicators[i].setBackgroundResource(R.drawable.indicators_default); if (i == 0) { indicators[i].setBackgroundResource(R.drawable.indicators_now); } indicatorLayout.addView(indicators[i]); } PagerAdapter pagerAdapter = new WelcomePagerAdapter(views); viewPager.setAdapter(pagerAdapter); // ? viewPager.setOnPageChangeListener(this); }
From source file:com.example.propertylist.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_project_sales_list); ImageView mImageView = new ImageView(this); DisplayMetrics metrics;/*from w ww .j a va2s. c om*/ int mScreenWidth; int mScreenHeight; api_key = getResources().getString(R.string.key); metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); mScreenWidth = metrics.widthPixels; mScreenHeight = metrics.heightPixels; if (mScreenWidth >= minScreenwidth) { if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if (mScreenWidth >= minLandScreenwidth) { largeScreen = true; } } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { if (mScreenHeight > minLandScreenwidth) { largeScreen = true; } } } else { largeScreen = false; } BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), R.id.daft_logo_image, options); mImageView.setImageBitmap( // ensure image size is 100 x 100. decodeSampledBitmapFromResource(getResources(), R.id.daft_logo_image, 100, 100)); handler = new Handler() { @Override public void handleMessage(Message msg) { hideProgressDialog(); startListActivity(); } }; }
From source file:com.airad.zhonghan.PullToRefreshListFragmentActivity.java
/** Called when the activity is first created. */ @Override/*from ww w.j a va 2 s . com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ptr_list_fragment); mPullRefreshListFragment = (PullToRefreshListFragment) getSupportFragmentManager() .findFragmentById(R.id.frag_ptr_list); // Get PullToRefreshListView from Fragment mPullRefreshListView = mPullRefreshListFragment.getPullToRefreshListView(); // Set a listener to be invoked when the list should be refreshed. mPullRefreshListView.setOnRefreshListener(this); // You can also just use mPullRefreshListFragment.getListView() ListView actualListView = mPullRefreshListView.getRefreshableView(); mListItems = new LinkedList<String>(); mListItems.addAll(Arrays.asList(mStrings)); mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mListItems); ImageView img = new ImageView(this); img.setImageResource(R.drawable.ic_action_search); actualListView.addHeaderView(img); // You can also just use setListAdapter(mAdapter) or // mPullRefreshListView.setAdapter(mAdapter) actualListView.setAdapter(mAdapter); mPullRefreshListFragment.setListShown(true); }
From source file:com.microsoft.assetmanagement.adapters.DisplayCarAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { CarListViewItem item = mData.get(position); ImageView imageView = null;/*from w w w.j av a2 s .c om*/ byte[] picture = item.getPicture(); imageView = new ImageView(mActivity); try { imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); imageView.setImageBitmap(mResizer.getBitmapFrom(picture)); ((ViewPager) container).addView(imageView, 0); } catch (Exception e) { Log.e("Asset", e.getMessage()); } return imageView; }
From source file:com.liquid.wallpapers.free.core.wallpapers.WallpaperGalleryAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { Wallpaper wallpaper = this.wallpapers[position]; ImageView imageView = new ImageView(this.context); try {/*from ww w . j a va2 s.c om*/ imageView.setImageBitmap(this.wallpaperManager.getThumbImage(wallpaper)); } catch (ClientProtocolException ex) { AlertDialogFactory.showErrorMessage(this.context, R.string.errorText, R.string.downloadException); } catch (IOException ex) { AlertDialogFactory.showErrorMessage(this.context, R.string.errorText, R.string.downloadException); } return imageView; }
From source file:org.gateshipone.malp.application.views.AlbumArtistView.java
public AlbumArtistView(Context context, AttributeSet attrs) { super(context, attrs); setMeasureAllChildren(true);//from ww w . j a va 2 s. c om // Set animation for a smooth image transition setInAnimation(AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_in)); setOutAnimation(AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_out)); // Ensure that the childs follow the size of the parent LayoutParams paramsAlbum = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); LayoutParams paramsArtist = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); // Create two image views mAlbumImage = new ImageView(context); mArtistImage = new ImageView(context); // Add them as a child addView(mAlbumImage); addView(mArtistImage); // Set layout parameters mAlbumImage.setLayoutParams(paramsAlbum); mArtistImage.setLayoutParams(paramsArtist); // Set the placeholder image clearAlbumImage(); mSwitchTimer = null; }
From source file:com.manning.androidhacks.hack008.MainActivity.java
private ImageView createNewView() { ImageView ret = new ImageView(this); ret.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); ret.setScaleType(ScaleType.FIT_XY);/*from ww w. j a va2 s . c om*/ ret.setImageResource(PHOTOS[mIndex]); mIndex = (mIndex + 1 < PHOTOS.length) ? mIndex + 1 : 0; return ret; }
From source file:com.clov4r.moboplayer.android.nil.codec.activity.MoboThumbnailTestActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); imageView = new ImageView(this); SubtitleJni h = new SubtitleJni(); String libpath = getFilesDir().getParent() + "/lib/"; String libname = "libffmpeg.so";// libffmpeg_armv7_neon.so h.loadFFmpegLibs(libpath, libname);//from www . j av a2 s.c o m Button button = new Button(this); layout.addView(button); layout.addView(imageView); button.setText(""); setContentView(layout); button.setOnClickListener(mOnClickListener); }
From source file:nl.timmevandermeer.carglass.LocationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mMapView = new ImageView(this); setContentView(mMapView);//from w w w. ja v a 2s. c o m loadMap(37.8019, -122.4189, 18); }