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.woofer.activity.personHomeActivity.java

public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.LEFT;
    layoutParams.leftMargin = 30;//from w  w  w.  ja  v  a 2  s  .  c om
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 30; i++) {

        TableRow tableRow = new TableRow(this);
        TextView textView7 = new TextView(this);
        textView7.setText("" + i);
        textView7.setTextSize(18);
        textView7.setTextColor(Color.rgb(0, 0, 0));

        textView7.setPadding(15, 0, 15, 0);
        tableRow.addView(textView7, layoutParams);
        tableRow.setBackgroundColor(Color.WHITE);

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);

        TableRow tableRow1 = new TableRow(this);
        TextView textView1 = new TextView(this);
        textView1.setText("Test pull down scrollvsfadasdsadsasadsadsadsadsadasdsadasdasdsadsaddasdiew " + i);
        textView1.setTextSize(16);
        textView1.setPadding(15, 0, 15, 15);
        tableRow1.addView(textView1, layoutParams);
        tableRow1.setBackgroundColor(Color.WHITE);

        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });
        mMainLayout.addView(tableRow1);

        //            TableRow tableRow2 = new TableRow(this);
        //            //tableRow2.addView(textView2, layoutParams);
        //            ImageView imageView = new ImageView(this);
        //            imageView.setImageResource(R.drawable.icon_reply_t);
        //            imageView.setScaleX((float) a);
        //            imageView.setScaleY((float) a);
        //            imageView.setPadding(0, 0, 0, 0);
        //
        //            ImageView imageView1 = new ImageView(this);
        //            imageView1.setImageResource(R.drawable.icon_thumb_t);
        //            imageView1.setScaleX((float) a);
        //            imageView1.setScaleY((float) a);
        //            imageView1.setPadding(0, 0, 0, 0);
        //
        //
        //            //tableRow2.addView(imageView);
        //            tableRow2.addView(imageView1);
        //            mMainLayout.addView(tableRow2);
        TableLayout mytable = (TableLayout) findViewById(R.id.degital_textTL);
        int numberOfRow = 1;
        int numberOfColumn = 12;
        int cellDimension = 24;
        int cellPadding = 200;
        for (int row = 0; row < numberOfRow; row++) {
            tableRow = new TableRow(this);
            //tableRow.setLayoutParams(new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT));
            tableRow.setLayoutParams(new TableLayout.LayoutParams(
                    (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));

            for (int column = 0; column < numberOfColumn; column++) {
                if (column % 3 == 0) {
                    TextView textView = new TextView(this);
                    textView.setTextSize(20);
                    textView.setText("   ");
                    tableRow.addView(textView);
                }
                if (column % 3 == 1) {
                    if (column == 1) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_eye_t);
                        tableRow.addView(imageView);
                    }
                    if (column == 4) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_thumb_t);
                        tableRow.addView(imageView);
                    }
                    if (column == 7) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_reply_t);
                        tableRow.addView(imageView);
                    }
                    if (column == 10) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_pencil_t);
                        tableRow.addView(imageView);
                    }
                }
                if (column % 3 == 2) {
                    if (column == 2) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                    if (column == 5) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                    if (column == 8) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                    if (column == 11) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                }

            }
            mytable.addView(tableRow, new TableLayout.LayoutParams(
                    (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));
            //mytable.addView(tableRow,new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT));
        }

    }
}

From source file:com.alburivan.slickform.tooltip.SimpleTooltip.java

private void configContentView() {
    if (mContentView instanceof TextView) {
        TextView tv = (TextView) mContentView;
        tv.setText(mText);//  w ww  . j  a v  a2 s .  c om
    } else {
        TextView tv = (TextView) mContentView.findViewById(mTextViewId);
        if (tv != null)
            tv.setText(mText);
    }

    mContentView.setPadding((int) mPadding, (int) mPadding, (int) mPadding, (int) mPadding);

    if (mShowArrow) {
        mArrowView = new ImageView(mContext);
        mArrowView.setImageDrawable(mArrowDrawable);
        LinearLayoutCompat.LayoutParams arrowLayoutParams;
        if (mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM) {
            arrowLayoutParams = new LinearLayoutCompat.LayoutParams((int) mArrowWidth, (int) mArrowHeight, 0);
        } else {
            arrowLayoutParams = new LinearLayoutCompat.LayoutParams((int) mArrowHeight, (int) mArrowWidth, 0);
        }
        mArrowView.setLayoutParams(arrowLayoutParams);
        LinearLayoutCompat linearLayout = new LinearLayoutCompat(mContext);
        linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        linearLayout.setOrientation(
                mGravity == Gravity.START || mGravity == Gravity.END ? LinearLayoutCompat.HORIZONTAL
                        : LinearLayoutCompat.VERTICAL);
        int padding = mAnimated ? mAnimationPadding : (int) SimpleTooltipUtils.pxFromDp(4);
        linearLayout.setPadding(padding, padding, padding, padding);

        if (mGravity == Gravity.TOP || mGravity == Gravity.START) {
            linearLayout.addView(mContentView);
            linearLayout.addView(mArrowView);
        } else {
            linearLayout.addView(mArrowView);
            linearLayout.addView(mContentView);
        }

        LinearLayoutCompat.LayoutParams contentViewParams = new LinearLayoutCompat.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0);
        contentViewParams.gravity = Gravity.CENTER;
        mContentView.setLayoutParams(contentViewParams);

        mContentLayout = linearLayout;
    } else {
        mContentLayout = mContentView;
        mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
    }
    mContentLayout.setVisibility(View.INVISIBLE);
    mPopupWindow.setContentView(mContentLayout);
}

From source file:com.example.view.astuetz.PagerSlidingTabStrip.java

@SuppressLint("NewApi")
private void addIconTab(int position, int resId, String notification) {
    FrameLayout tabItemCon = new FrameLayout(getContext());
    ImageView tab = new ImageView(getContext());
    tab.setImageResource(resId);/* w ww.j  av  a2  s  .c o m*/
    tabItemCon.addView(tab);
    tabIconlist.put(position, tab);
    ImageView notiSymbol = new ImageView(getContext());
    notiSymbol.setImageResource(R.drawable.badge_background);
    BadgeView noti = new BadgeView(getContext());
    noti.setText(notification);
    tabItemCon.addView(noti);
    tabItemCon.addView(notiSymbol);
    if (notification != null && !notification.equals("")) {
        noti.setVisibility(View.VISIBLE);
        notiSymbol.setVisibility(View.GONE);
    } else if (notification != null && notification.equals("")) {
        noti.setVisibility(View.GONE);
        notiSymbol.setVisibility(View.VISIBLE);
    } else {
        notiSymbol.setVisibility(View.GONE);
        noti.setVisibility(View.GONE);
    }
    int notiSySize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20,
            getResources().getDisplayMetrics());
    noti.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
            Gravity.RIGHT | Gravity.TOP));
    notiSymbol.setLayoutParams(new LayoutParams(notiSySize, notiSySize, Gravity.RIGHT | Gravity.TOP));
    FrameLayout tabItem = new FrameLayout(getContext());
    tabItem.addView(tabItemCon);
    tabItemCon.setLayoutParams(
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER));
    addTab(position, tabItem);
}

From source file:org.lol.reddit.activities.ImageViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences);

    if (solidblack)
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));

    final Intent intent = getIntent();

    mUrl = General.uriFromString(intent.getDataString());
    final RedditPost src_post = intent.getParcelableExtra("post");

    if (mUrl == null) {
        General.quickToast(this, "Invalid URL. Trying web browser.");
        revertToWeb();//from  www  .j a va2 s  . c om
        return;
    }

    Log.i("ImageViewActivity", "Loading URL " + mUrl.toString());

    final ProgressBar progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);

    final LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(progressBar);

    CacheManager.getInstance(this)
            .makeRequest(new CacheRequest(mUrl, RedditAccountManager.getAnon(), null,
                    Constants.Priority.IMAGE_VIEW, 0, CacheRequest.DownloadType.IF_NECESSARY,
                    Constants.FileType.IMAGE, false, false, false, this) {

                private void setContentView(View v) {
                    layout.removeAllViews();
                    layout.addView(v);
                    v.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
                    v.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
                }

                @Override
                protected void onCallbackException(Throwable t) {
                    BugReportActivity.handleGlobalError(context.getApplicationContext(),
                            new RRError(null, null, t));
                }

                @Override
                protected void onDownloadNecessary() {
                    General.UI_THREAD_HANDLER.post(new Runnable() {
                        @Override
                        public void run() {
                            progressBar.setVisibility(View.VISIBLE);
                            progressBar.setIndeterminate(true);
                        }
                    });
                }

                @Override
                protected void onDownloadStarted() {
                }

                @Override
                protected void onFailure(final RequestFailureType type, Throwable t, StatusLine status,
                        final String readableMessage) {

                    final RRError error = General.getGeneralErrorForFailure(context, type, t, status,
                            url.toString());

                    General.UI_THREAD_HANDLER.post(new Runnable() {
                        public void run() {
                            // TODO handle properly
                            progressBar.setVisibility(View.GONE);
                            layout.addView(new ErrorView(ImageViewActivity.this, error));
                        }
                    });
                }

                @Override
                protected void onProgress(final long bytesRead, final long totalBytes) {
                    General.UI_THREAD_HANDLER.post(new Runnable() {
                        @Override
                        public void run() {
                            progressBar.setVisibility(View.VISIBLE);
                            progressBar.setIndeterminate(false);
                            progressBar.setProgress((int) ((100 * bytesRead) / totalBytes));
                        }
                    });
                }

                @Override
                protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, long timestamp,
                        UUID session, boolean fromCache, final String mimetype) {

                    if (mimetype == null || !Constants.Mime.isImage(mimetype)) {
                        revertToWeb();
                        return;
                    }

                    final InputStream cacheFileInputStream;
                    try {
                        cacheFileInputStream = cacheFile.getInputStream();
                    } catch (IOException e) {
                        notifyFailure(RequestFailureType.PARSE, e, null,
                                "Could not read existing cached image.");
                        return;
                    }

                    if (cacheFileInputStream == null) {
                        notifyFailure(RequestFailureType.CACHE_MISS, null, null, "Could not find cached image");
                        return;
                    }

                    if (Constants.Mime.isImageGif(mimetype)) {

                        if (AndroidApi.isIceCreamSandwichOrLater()) {

                            General.UI_THREAD_HANDLER.post(new Runnable() {
                                public void run() {
                                    try {
                                        final GIFView gifView = new GIFView(ImageViewActivity.this,
                                                cacheFileInputStream);
                                        setContentView(gifView);
                                        gifView.setOnClickListener(new View.OnClickListener() {
                                            public void onClick(View v) {
                                                finish();
                                            }
                                        });

                                    } catch (OutOfMemoryError e) {
                                        General.quickToast(context, R.string.imageview_oom);
                                        revertToWeb();

                                    } catch (Throwable e) {
                                        General.quickToast(context, R.string.imageview_invalid_gif);
                                        revertToWeb();
                                    }
                                }
                            });

                        } else {

                            gifThread = new GifDecoderThread(cacheFileInputStream,
                                    new GifDecoderThread.OnGifLoadedListener() {

                                        public void onGifLoaded() {
                                            General.UI_THREAD_HANDLER.post(new Runnable() {
                                                public void run() {
                                                    imageView = new ImageView(context);
                                                    imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
                                                    setContentView(imageView);
                                                    gifThread.setView(imageView);

                                                    imageView.setOnClickListener(new View.OnClickListener() {
                                                        public void onClick(View v) {
                                                            finish();
                                                        }
                                                    });
                                                }
                                            });
                                        }

                                        public void onOutOfMemory() {
                                            General.quickToast(context, R.string.imageview_oom);
                                            revertToWeb();
                                        }

                                        public void onGifInvalid() {
                                            General.quickToast(context, R.string.imageview_invalid_gif);
                                            revertToWeb();
                                        }
                                    });

                            gifThread.start();

                        }

                    } else {

                        final long bytes = cacheFile.getSize();
                        final byte[] buf = new byte[(int) bytes];

                        try {
                            new DataInputStream(cacheFileInputStream).readFully(buf);
                        } catch (IOException e) {
                            throw new RuntimeException(e);
                        }

                        final ImageTileSource imageTileSource;
                        try {
                            imageTileSource = new ImageTileSourceWholeBitmap(buf);

                        } catch (OutOfMemoryError e) {
                            General.quickToast(context, R.string.imageview_oom);
                            revertToWeb();
                            return;

                        } catch (Throwable t) {
                            Log.e("ImageViewActivity", "Exception when creating ImageTileSource", t);
                            General.quickToast(context, R.string.imageview_decode_failed);
                            revertToWeb();
                            return;
                        }

                        General.UI_THREAD_HANDLER.post(new Runnable() {
                            public void run() {

                                surfaceView = new RRGLSurfaceView(ImageViewActivity.this,
                                        new ImageViewDisplayListManager(imageTileSource,
                                                ImageViewActivity.this));
                                setContentView(surfaceView);

                                surfaceView.setOnClickListener(new View.OnClickListener() {
                                    public void onClick(View v) {
                                        finish();
                                    }
                                });

                                if (mIsPaused) {
                                    surfaceView.onPause();
                                } else {
                                    surfaceView.onResume();
                                }
                            }
                        });
                    }
                }
            });

    final RedditPreparedPost post = src_post == null ? null
            : new RedditPreparedPost(this, CacheManager.getInstance(this), 0, src_post, -1, false, false, false,
                    false, RedditAccountManager.getInstance(this).getDefaultAccount(), false);

    final FrameLayout outerFrame = new FrameLayout(this);
    outerFrame.addView(layout);

    if (post != null) {

        final SideToolbarOverlay toolbarOverlay = new SideToolbarOverlay(this);

        final BezelSwipeOverlay bezelOverlay = new BezelSwipeOverlay(this,
                new BezelSwipeOverlay.BezelSwipeListener() {

                    public boolean onSwipe(BezelSwipeOverlay.SwipeEdge edge) {

                        toolbarOverlay.setContents(
                                post.generateToolbar(ImageViewActivity.this, false, toolbarOverlay));
                        toolbarOverlay.show(edge == BezelSwipeOverlay.SwipeEdge.LEFT
                                ? SideToolbarOverlay.SideToolbarPosition.LEFT
                                : SideToolbarOverlay.SideToolbarPosition.RIGHT);
                        return true;
                    }

                    public boolean onTap() {

                        if (toolbarOverlay.isShown()) {
                            toolbarOverlay.hide();
                            return true;
                        }

                        return false;
                    }
                });

        outerFrame.addView(bezelOverlay);
        outerFrame.addView(toolbarOverlay);

        bezelOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
        bezelOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;

        toolbarOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
        toolbarOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;

    }

    setContentView(outerFrame);
}

From source file:com.cube.storm.ui.view.PagerSlidingTabStrip.java

private void addIconTab(final int position, Bitmap bitmap) {
    ImageView tab = new ImageView(getContext());
    tab.setImageBitmap(bitmap);//  w  w w  . j a  v a 2  s .co  m
    tab.setColorFilter(tabIconTint);
    tab.setScaleType(ScaleType.FIT_CENTER);

    DisplayMetrics dm = getResources().getDisplayMetrics();
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm);

    tab.setPadding(padding + tabPadding, padding, padding + tabPadding, padding);

    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(android.view.View v) {
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.esri.arcgisruntime.sample.editfeatureattachments.MainActivity.java

/**
 * Create a Layout for callout//  w  w w.ja va 2 s  . c  o  m
 */
private void createCallout() {

    // create content text view for the callout
    mCalloutLayout = new RelativeLayout(getApplicationContext());
    TextView calloutContent = new TextView(getApplicationContext());
    calloutContent.setId(R.id.calloutTextView);
    calloutContent.setTextColor(Color.BLACK);
    calloutContent.setTextSize(18);

    RelativeLayout.LayoutParams relativeParamsBelow = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    relativeParamsBelow.addRule(RelativeLayout.BELOW, calloutContent.getId());

    // create attachment text view for the callout
    TextView calloutAttachment = new TextView(getApplicationContext());
    calloutAttachment.setId(R.id.attchTV);
    calloutAttachment.setTextColor(Color.BLACK);
    calloutAttachment.setTextSize(13);
    calloutContent.setPadding(0, 20, 20, 0);
    calloutAttachment.setLayoutParams(relativeParamsBelow);

    RelativeLayout.LayoutParams relativeParamsRightOf = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    relativeParamsRightOf.addRule(RelativeLayout.RIGHT_OF, calloutAttachment.getId());

    // create image view for the callout
    ImageView imageView = new ImageView(getApplicationContext());
    imageView.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_info));
    imageView.setLayoutParams(relativeParamsRightOf);
    imageView.setOnClickListener(new ImageViewOnclickListener());

    mCalloutLayout.addView(calloutContent);
    mCalloutLayout.addView(imageView);
    mCalloutLayout.addView(calloutAttachment);

}

From source file:com.witmoon.xmb.ui.widget.PagerSlidingTabStrip.java

private void addTextIconTab(final int position, String title, int resId) {

    if (resId == TitleIconTabProvider.NONE_ICON) {
        addTextTab(position, title);//from w w  w . ja va  2 s  . c  om
        return;
    }

    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    ImageView icon = new ImageView(getContext());

    if (position == 1) {
        icon.setImageResource(icoColor1);
    } else {
        icon.setImageResource(selectedIcoColor);
    }

    LinearLayout linearLayout = new LinearLayout(getContext());
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.addView(icon, defaultTabLayoutParams);
    linearLayout.addView(tab, defaultTabLayoutParams);

    addTab(position, linearLayout);
}

From source file:com.oasis.sdk.activity.OasisSdkPayEpinActivity.java

private void initImage(List<String> imgUrls) {
    if (imgUrls == null || imgUrls.size() <= 0)
        return;/*from  ww w  . j  a v  a2 s.c  om*/

    int size = imgUrls.size();
    if (size > 4)// 4
        size = 4;
    Rect r = new Rect();
    et_code.getGlobalVisibleRect(r);

    int width = r.right - r.left;
    int singWidth = width / size;

    int imgWidth = DisplayUtil.dip2px(70, BaseUtils.getDensity());
    int imgHeight = DisplayUtil.dip2px(30, BaseUtils.getDensity());

    double l = singWidth / (double) imgWidth;
    if (l <= 1) {
        imgWidth = singWidth;
    } else {
        l = Math.round(l * 100) * 0.01d;// ?2??

        imgWidth *= l;
        imgHeight *= l;
    }

    for (int i = 0; i < size; i++) {
        // ? 105*45
        final ImageView img = new ImageView(this.getApplicationContext());
        img.setLayoutParams(new LayoutParams(imgWidth, imgHeight));
        img.setImageResource(BaseUtils.getResourceValue("drawable", "oasisgames_sdk_payway_mob_epin"));
        ImageRequest iq = new ImageRequest(imgUrls.get(i), new Response.Listener<Bitmap>() {

            @Override
            public void onResponse(final Bitmap arg0) {
                if (arg0 == null)
                    return;
                img.setImageBitmap(arg0);
                img.postInvalidate();
            }
        }, imgWidth, // ???
                imgHeight, Config.ARGB_8888, new Response.ErrorListener() {

                    @Override
                    public void onErrorResponse(VolleyError arg0) {

                        setWaitScreen(false);
                    }

                });
        iq.setRetryPolicy(new DefaultRetryPolicy(60000, 2, 1));
        ApplicationContextManager.getInstance().getVolleyRequestQueue().add(iq);

        ll_images.addView(img);
    }
    if (ll_images.getChildCount() > 0) {
        ll_images.setVisibility(View.VISIBLE);
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppObj.java

@Override
public void render(final Context context, final ViewGroup frame, Obj obj, boolean allowInteractions) {
    PackageManager pm = context.getPackageManager();
    Drawable icon = null;/*w  w  w  .  ja  v  a  2 s. c o m*/
    String appName;
    if (obj.getJson() != null && obj.getJson().has(ANDROID_PACKAGE_NAME)) {
        appName = obj.getJson().optString(ANDROID_PACKAGE_NAME);
    } else {
        appName = "Unknown";
    }
    if (!(obj instanceof DbObj)) {
        if (appName.contains(".")) {
            appName = appName.substring(appName.lastIndexOf(".") + 1);
        }
        String text = "Preparing application " + appName + "...";
        // TODO: Show Market icon or app icon.
        TextView valueTV = new TextView(context);
        valueTV.setText(text);
        valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
        frame.addView(valueTV);
        return;
    }

    DbObj dbParentObj = (DbObj) obj;
    boolean rendered = false;

    Intent launch = getLaunchIntent(context, dbParentObj);
    List<ResolveInfo> infos = pm.queryIntentActivities(launch, 0);
    if (infos.size() > 0) {
        ResolveInfo info = infos.get(0);
        if (info.activityInfo.labelRes != 0) {
            appName = info.activityInfo.loadLabel(pm).toString();
            icon = info.loadIcon(pm);
        } else {
            appName = info.activityInfo.name;
        }
    } else {
        appName = obj.getJson().optString(ANDROID_PACKAGE_NAME);
        if (appName.contains(".")) {
            appName = appName.substring(appName.lastIndexOf(".") + 1);
        }
    }
    // TODO: Safer reference to containing view
    if (icon != null) {
        View parentView = (View) frame.getParent().getParent();
        ImageView avatar = (ImageView) parentView.findViewById(R.id.icon);
        avatar.setImageDrawable(icon);

        TextView label = (TextView) parentView.findViewById(R.id.name_text);
        label.setText(appName);
    }

    // TODO: obj.getLatestChild().render();
    String selection = getRenderableClause();
    String[] selectionArgs = null;
    Cursor cursor = dbParentObj.getSubfeed().query(selection, selectionArgs);
    if (cursor.moveToFirst()) {
        DbObj dbObj = App.instance().getMusubi().objForCursor(cursor);
        DbObjects.getFeedRenderer(dbObj.getType()).render(context, frame, dbObj, allowInteractions);
        rendered = true;
    }

    if (!rendered) {
        String text;
        if (icon != null) {
            ImageView iv = new ImageView(context);
            iv.setImageDrawable(icon);
            iv.setAdjustViewBounds(true);
            iv.setMaxWidth(60);
            iv.setMaxHeight(60);
            iv.setLayoutParams(CommonLayouts.WRAPPED);
            frame.addView(iv);
            text = appName;
        } else {
            text = "New application: " + appName + ".";
        }
        // TODO: Show Market icon or app icon.
        TextView valueTV = new TextView(context);
        valueTV.setText(text);
        valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
        frame.addView(valueTV);
    }
}

From source file:com.googlecode.android_scripting.activity.Main.java

protected void initializeViews() {
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    layout.setGravity(Gravity.CENTER_HORIZONTAL);
    TextView textview = new TextView(this);
    textview.setText(" PhpForAndroid " + version);
    ImageView imageView = new ImageView(this);
    imageView.setImageDrawable(getResources().getDrawable(R.drawable.pfa));
    layout.addView(imageView);//from   ww  w .ja  v a 2  s . c  o  m
    mButton = new Button(this);
    mAboutButton = new Button(this);
    MarginLayoutParams marginParams = new MarginLayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);
    final float scale = getResources().getDisplayMetrics().density;
    int marginPixels = (int) (MARGIN_DIP * scale + 0.5f);
    marginParams.setMargins(marginPixels, marginPixels, marginPixels, marginPixels);
    mButton.setLayoutParams(marginParams);
    mAboutButton.setLayoutParams(marginParams);
    layout.addView(textview);
    layout.addView(mButton);
    layout.addView(mAboutButton);

    mProgressLayout = new LinearLayout(this);
    mProgressLayout.setOrientation(LinearLayout.HORIZONTAL);
    mProgressLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mProgressLayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);

    LinearLayout bottom = new LinearLayout(this);
    bottom.setOrientation(LinearLayout.HORIZONTAL);
    bottom.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    bottom.setGravity(Gravity.CENTER_VERTICAL);
    mProgressLayout.addView(bottom);

    TextView message = new TextView(this);
    message.setText("   In Progress...");
    message.setTextSize(20);
    message.setTypeface(Typeface.DEFAULT_BOLD);
    message.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    ProgressBar bar = new ProgressBar(this);
    bar.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    bottom.addView(bar);
    bottom.addView(message);
    mProgressLayout.setVisibility(View.INVISIBLE);

    layout.addView(mProgressLayout);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setProgressBarIndeterminateVisibility(false);

    setContentView(layout);
}