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.example.drugsformarinemammals.General_Info_Drug.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.general_info_drug);
    isStoredInLocal = false;/*w  ww  .j  a v a  2 s  .  co m*/
    fiveLastScreen = false;
    helper = new Handler_Sqlite(this);
    helper.open();
    Bundle extras1 = this.getIntent().getExtras();
    if (extras1 != null) {
        infoBundle = extras1.getStringArrayList("generalInfoDrug");
        fiveLastScreen = extras1.getBoolean("fiveLastScreen");
        if (infoBundle == null)
            isStoredInLocal = true;
        if (!isStoredInLocal) {
            initializeGeneralInfoDrug();
            initializeCodesInformation();
            initializeCodes();
        } else {
            drug_name = extras1.getString("drugName");
            codes = helper.getCodes(drug_name);
            codesInformation = helper.getCodesInformation(drug_name);
        }
        //Title
        TextView drugTitle = (TextView) findViewById(R.id.drugTitle);
        drugTitle.setText(drug_name);
        drugTitle.setTypeface(Typeface.SANS_SERIF);

        //Description 
        LinearLayout borderDescription = new LinearLayout(this);
        borderDescription.setOrientation(LinearLayout.VERTICAL);
        borderDescription
                .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        borderDescription.setBackgroundResource(R.drawable.layout_border);

        TextView description = new TextView(this);
        if (isStoredInLocal)
            description.setText(helper.getDescription(drug_name));
        else
            description.setText(this.description);
        description.setTextSize(18);
        description.setTypeface(Typeface.SANS_SERIF);

        LinearLayout.LayoutParams paramsDescription = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsDescription.leftMargin = 60;
        paramsDescription.rightMargin = 60;
        paramsDescription.topMargin = 20;

        borderDescription.addView(description, borderDescription.getChildCount(), paramsDescription);

        LinearLayout layoutDescription = (LinearLayout) findViewById(R.id.layoutDescription);
        layoutDescription.addView(borderDescription, layoutDescription.getChildCount());

        //Animals
        TextView headerAnimals = (TextView) findViewById(R.id.headerAnimals);
        headerAnimals.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        Button cetaceansButton = (Button) findViewById(R.id.cetaceansButton);
        cetaceansButton.setText("CETACEANS");
        cetaceansButton.setTypeface(Typeface.SANS_SERIF);
        cetaceansButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Cetaceans");
            }
        });

        Button pinnipedsButton = (Button) findViewById(R.id.pinnipedsButton);
        pinnipedsButton.setText("PINNIPEDS");
        pinnipedsButton.setTypeface(Typeface.SANS_SERIF);
        pinnipedsButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                SQLiteDatabase db = helper.open();
                ArrayList<String> families = new ArrayList<String>();
                if (db != null)
                    families = helper.read_animals_family(drug_name, "Pinnipeds");
                if ((families != null && families.size() == 1 && families.get(0).equals(""))
                        || (families != null && families.size() == 0))
                    showDoseInformation(drug_name, "Pinnipeds");
                else
                    showDoseInformationPinnipeds(drug_name, families);
            }
        });

        Button otherButton = (Button) findViewById(R.id.otherButton);
        otherButton.setText("OTHER MM");
        otherButton.setTypeface(Typeface.SANS_SERIF);
        otherButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Other MM");
            }
        });

        //Codes & therapeutic target & anatomical target
        TextView headerATCvetCodes = (TextView) findViewById(R.id.headerATCvetCodes);
        headerATCvetCodes.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        //Action
        TextView headerActionAnatomical = (TextView) findViewById(R.id.headerActionAnatomical);
        headerActionAnatomical.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewAnatomical();
        createBorderAnatomicalGroup();

        TextView headerActionTherapeutic = (TextView) findViewById(R.id.headerActionTherapeutic);
        headerActionTherapeutic.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewTherapeutic();
        createBorderTherapeuticGroup();

        params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.leftMargin = 60;
        params.rightMargin = 60;
        params.topMargin = 20;

        Spinner codesSpinner = (Spinner) findViewById(R.id.codesSpinner);
        SpinnerAdapter adapterCodes = new SpinnerAdapter(this, R.layout.item_spinner, codes);
        adapterCodes.setDropDownViewResource(R.layout.spinner_dropdown_item);
        codesSpinner.setAdapter(adapterCodes);
        codesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

            public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
                userEntryCode = parent.getSelectedItem().toString();
                int numCodes = codesInformation.size();

                layoutAnatomicalGroup.removeView(borderAnatomicalGroup);
                createBorderAnatomicalGroup();

                boolean founded = false;
                int i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewAnatomical();
                        anatomicalGroup.setText(codesInformation.get(i).getAnatomic_group() + "\n");
                        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }

                layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
                layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
                layoutTherapeuticGroup.removeView(borderTherapeuticGroup);
                createBorderTherapeuticGroup();
                founded = false;
                i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewTherapeutic();
                        therapeuticGroup.setText(codesInformation.get(i).getTherapeutic_group() + "\n");
                        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }
                layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);
                layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());
            }

            public void onNothingSelected(AdapterView<?> arg0) {
            }
        });

        layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
        layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);

        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params);
        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params);

        layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
        layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());

        //Generic Drug
        TextView headerGenericDrug = (TextView) findViewById(R.id.headerGenericDrug);
        headerGenericDrug.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
        boolean isAvalaible = false;
        if (isStoredInLocal)
            isAvalaible = helper.isAvalaible(drug_name);
        else
            isAvalaible = available.equals("Yes");
        if (isAvalaible) {
            ImageView genericDrug = new ImageView(this);
            genericDrug.setImageResource(R.drawable.tick_verde);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        } else {
            Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
            TextView genericDrug = new TextView(this);
            genericDrug.setTypeface(font);
            genericDrug.setText("Nd");
            genericDrug.setTextColor(getResources().getColor(R.color.maroon));
            genericDrug.setTextSize(20);
            DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            int size = metrics.widthPixels;
            int middle = size / 2;
            int quarter = size / 4;
            genericDrug.setTranslationX(middle - quarter);
            genericDrug.setTranslationY(-3);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        }

        //Licenses
        TextView headerLicense = (TextView) findViewById(R.id.headerLicense);
        headerLicense.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        TextView fdaLicense = (TextView) findViewById(R.id.license1);
        Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
        fdaLicense.setTypeface(font);

        String fda;
        if (isStoredInLocal)
            fda = helper.getLicense_FDA(drug_name);
        else
            fda = license_FDA;
        if (fda.equals("Yes")) {
            fdaLicense.setText("Yes");
            fdaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            fdaLicense.setText("Nd");
            fdaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView emaLicense = (TextView) findViewById(R.id.license3);
        emaLicense.setTypeface(font);
        String ema;
        if (isStoredInLocal)
            ema = helper.getLicense_EMA(drug_name);
        else
            ema = license_EMA;
        if (ema.equals("Yes")) {
            emaLicense.setText("Yes");
            emaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            emaLicense.setText("Nd");
            emaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView aempsLicense = (TextView) findViewById(R.id.license2);
        aempsLicense.setTypeface(font);
        String aemps;
        if (isStoredInLocal)
            aemps = helper.getLicense_AEMPS(drug_name);
        else
            aemps = license_AEMPS;
        if (aemps.equals("Yes")) {
            aempsLicense.setText("Yes");
            aempsLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            aempsLicense.setText("Nd");
            aempsLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        ImageButton food_and_drug = (ImageButton) findViewById(R.id.food_and_drug);
        food_and_drug.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.fda.gov/animalveterinary/products/approvedanimaldrugproducts/default.htm"));
                startActivity(intent);
            }
        });

        ImageButton european_medicines_agency = (ImageButton) findViewById(R.id.european_medicines_agency);
        european_medicines_agency.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.ema.europa.eu/ema/index.jsp?curl=pages/medicines/landing/vet_epar_search.jsp&mid=WC0b01ac058001fa1c"));
                startActivity(intent);
            }
        });

        ImageButton logo_aemps = (ImageButton) findViewById(R.id.logo_aemps);
        logo_aemps.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.aemps.gob.es/medicamentosVeterinarios/Med-Vet-autorizados/home.htm"));
                startActivity(intent);
            }

        });

        if (helper.existDrug(drug_name)) {
            int drug_priority = helper.getDrugPriority(drug_name);
            ArrayList<String> sorted_drugs = new ArrayList<String>();
            sorted_drugs.add(0, drug_name);
            for (int i = 1; i < drug_priority; i++) {
                String name = helper.getDrugName(i);
                sorted_drugs.add(i, name);
            }

            for (int i = 0; i < sorted_drugs.size(); i++)
                helper.setDrugPriority(sorted_drugs.get(i), i + 1);
        }

        if (!isStoredInLocal) {
            //Server code
            String[] urls = { "http://formmulary.tk/Android/getDoseInformation.php?drug_name=",
                    "http://formmulary.tk/Android/getGeneralNotesInformation.php?drug_name=" };
            new GetDoseInformation(this).execute(urls);
        }

        helper.close();
    }

}

From source file:com.example.fragmentdemo.views.PagerSlidingTabStrip.java

private void addTab(final int position, CharSequence title, int iconResId, int iLayoutResId, int iTextId,
        int iIconLocation) {
    // final View tabView = ((Activity) getContext()).getLayoutInflater()
    // .inflate(iLayoutResId, null);
    // TextView tab_text_textview = (TextView)
    // tabView.findViewById(iTextId);
    // tab_text_textview.setText(title);
    LinearLayout tabView = new LinearLayout(getContext());
    tabView.setGravity(Gravity.CENTER);//ww  w  .  j a v  a  2 s.c om
    TextView tab_text_textview = new TextView(getContext());
    tab_text_textview.setId(position);
    tab_text_textview.setText(title);
    tab_text_textview.setGravity(Gravity.CENTER_VERTICAL);
    tab_text_textview.setSingleLine();
    // tab_text_textview.setTextColor(tabTextColor);
    // tab_text_textview.setTextColor(getResources().getColor(R.color.indicator_tab_main_text_color));
    XmlPullParser xrp = getResources().getXml(tabTextColor);
    try {
        ColorStateList csl = ColorStateList.createFromXml(getResources(), xrp);

        if (tab_text_textview != null) {
            tab_text_textview.setTextColor(csl);
        }
    } catch (Exception e) {

    }
    tab_text_textview.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
    tab_text_textview.setTypeface(tabTypeface, tabTypefaceStyle);
    LinearLayout.LayoutParams lpText = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    if (iconResId != 0) {
        // tab_text_textview.setCompoundDrawablesWithIntrinsicBounds(
        // iconResId, 0, 0, 0);
        // Drawable mDrawable = ((Activity) getContext()).getResources()
        // .getDrawable(iconResId);
        // mDrawable.setBounds(0, 0, mDrawable.getMinimumWidth(),
        // mDrawable.getMinimumHeight());
        int iPandding = (int) ((Activity) getContext()).getResources().getDimension(R.dimen.common_padding);
        ImageView icon = new ImageView(getContext());
        icon.setImageResource(iconResId);
        icon.setScaleType(ScaleType.CENTER_INSIDE);
        LinearLayout.LayoutParams lpImage = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                iIconHeight);

        switch (iIconLocation) {
        case 1:
            // tab_text_textview.setCompoundDrawables(mDrawable, null, null,
            // null);
            tabView.setOrientation(LinearLayout.HORIZONTAL);
            // tabView.setGravity(Gravity.CENTER_VERTICAL);

            tabView.addView(icon, lpImage);
            lpText.leftMargin = iPandding;
            tabView.addView(tab_text_textview, lpText);
            break;
        case 2:
            // tab_text_textview.setCompoundDrawables(null, mDrawable, null,
            // null);
            tabView.setOrientation(LinearLayout.VERTICAL);
            // tabView.setGravity(Gravity.CENTER_HORIZONTAL);
            tabView.addView(icon, lpImage);
            lpText.topMargin = iPandding;
            tabView.addView(tab_text_textview, lpText);
            break;
        case 3:
            // tab_text_textview.setCompoundDrawables(null, null, mDrawable,
            // null);
            tabView.setOrientation(LinearLayout.HORIZONTAL);
            // tabView.setGravity(Gravity.CENTER_VERTICAL);
            tabView.addView(tab_text_textview, lpText);
            lpImage.leftMargin = iPandding;
            tabView.addView(icon, lpImage);
            break;
        case 4:
            // tab_text_textview.setCompoundDrawables(null, null, null,
            // mDrawable);
            tabView.setOrientation(LinearLayout.VERTICAL);
            // tabView.setGravity(Gravity.CENTER_HORIZONTAL);
            tabView.addView(tab_text_textview, lpText);
            lpImage.topMargin = iPandding;
            tabView.addView(icon, lpImage);
            break;
        default:
            // tab_text_textview.setCompoundDrawables(mDrawable, null, null,
            // null);
            tabView.setOrientation(LinearLayout.HORIZONTAL);
            // tabView.setGravity(Gravity.CENTER_VERTICAL);
            tabView.addView(icon, lpImage);
            lpText.leftMargin = iPandding;
            tabView.addView(tab_text_textview, lpText);
            break;
        }

        // tab_text_textview
        // .setCompoundDrawablePadding((int) ((Activity) getContext())
        // .getResources()
        // .getDimension(R.dimen.common_padding));

    } else {
        tabView.addView(tab_text_textview, lpText);
    }

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

    // tab_text_textview.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tabView, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.wangbb.naruto.app.view.PagerSlidingTabStrip.java

private void addTab(final int position, CharSequence title, int iconResId, int iLayoutResId, int iTextId,
        int iIconLocation) {
    // final View tabView = ((Activity) getContext()).getLayoutInflater()
    // .inflate(iLayoutResId, null);
    // TextView tab_text_textview = (TextView)
    // tabView.findViewById(iTextId);
    // tab_text_textview.setText(title);
    LinearLayout tabView = new LinearLayout(getContext());
    tabView.setGravity(Gravity.CENTER);// w w w  .j av a 2s  .co m
    TextView tab_text_textview = new TextView(getContext());
    tab_text_textview.setId(position);
    tab_text_textview.setText(title);
    tab_text_textview.setGravity(Gravity.CENTER_VERTICAL);
    tab_text_textview.setSingleLine();
    // tab_text_textview.setTextColor(tabTextColor);
    // tab_text_textview.setTextColor(getResources().getColor(R.color.indicator_tab_main_text_color));
    //      XmlPullParser xrp = getResources().getXml(tabTextColor);
    //      try {
    //         ColorStateList csl = ColorStateList.createFromXml(getResources(),
    //               xrp);

    //         if (tab_text_textview != null) {
    tab_text_textview.setTextColor(tabTextColor);
    //         }
    //      } catch (Exception e) {
    //
    //      }
    tab_text_textview.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
    tab_text_textview.setTypeface(tabTypeface, tabTypefaceStyle);
    LinearLayout.LayoutParams lpText = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    if (iconResId != 0) {
        // tab_text_textview.setCompoundDrawablesWithIntrinsicBounds(
        // iconResId, 0, 0, 0);
        // Drawable mDrawable = ((Activity) getContext()).getResources()
        // .getDrawable(iconResId);
        // mDrawable.setBounds(0, 0, mDrawable.getMinimumWidth(),
        // mDrawable.getMinimumHeight());
        int iPandding = (int) ((Activity) getContext()).getResources().getDimension(R.dimen.common_padding);
        ImageView icon = new ImageView(getContext());
        icon.setImageResource(iconResId);
        icon.setScaleType(ScaleType.CENTER_INSIDE);
        LinearLayout.LayoutParams lpImage = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                iIconHeight);

        switch (iIconLocation) {
        case 1:
            // tab_text_textview.setCompoundDrawables(mDrawable, null, null,
            // null);
            tabView.setOrientation(LinearLayout.HORIZONTAL);
            // tabView.setGravity(Gravity.CENTER_VERTICAL);

            tabView.addView(icon, lpImage);
            lpText.leftMargin = iPandding;
            tabView.addView(tab_text_textview, lpText);
            break;
        case 2:
            // tab_text_textview.setCompoundDrawables(null, mDrawable, null,
            // null);
            tabView.setOrientation(LinearLayout.VERTICAL);
            // tabView.setGravity(Gravity.CENTER_HORIZONTAL);
            tabView.addView(icon, lpImage);
            lpText.topMargin = iPandding;
            tabView.addView(tab_text_textview, lpText);
            break;
        case 3:
            // tab_text_textview.setCompoundDrawables(null, null, mDrawable,
            // null);
            tabView.setOrientation(LinearLayout.HORIZONTAL);
            // tabView.setGravity(Gravity.CENTER_VERTICAL);
            tabView.addView(tab_text_textview, lpText);
            lpImage.leftMargin = iPandding;
            tabView.addView(icon, lpImage);
            break;
        case 4:
            // tab_text_textview.setCompoundDrawables(null, null, null,
            // mDrawable);
            tabView.setOrientation(LinearLayout.VERTICAL);
            // tabView.setGravity(Gravity.CENTER_HORIZONTAL);
            tabView.addView(tab_text_textview, lpText);
            lpImage.topMargin = iPandding;
            tabView.addView(icon, lpImage);
            break;
        default:
            // tab_text_textview.setCompoundDrawables(mDrawable, null, null,
            // null);
            tabView.setOrientation(LinearLayout.HORIZONTAL);
            // tabView.setGravity(Gravity.CENTER_VERTICAL);
            tabView.addView(icon, lpImage);
            lpText.leftMargin = iPandding;
            tabView.addView(tab_text_textview, lpText);
            break;
        }

        // tab_text_textview
        // .setCompoundDrawablePadding((int) ((Activity) getContext())
        // .getResources()
        // .getDimension(R.dimen.common_padding));

    } else {
        tabView.addView(tab_text_textview, lpText);
    }

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

    // tab_text_textview.setPadding(tabPadding, 0, tabPadding, 0);
    tabsContainer.addView(tabView, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:org.egov.android.view.activity.ComplaintDetailActivity.java

/**
 * Function called when the activity was created to show the images attached
 * with the complaints Get the files from the complaint folder path and show
 * that images in horizontal scroll view
 *///ww w  .ja  v  a2s.  c o m
private void _showComplaintImages() {
    File folder = new File(complaintFolderName);
    if (!folder.exists()) {
        return;
    }
    File[] listOfFiles = folder.listFiles();

    int imageidx = 0;

    for (int i = 0; i < listOfFiles.length; i++) {

        if (listOfFiles[i].isFile()) {
            Log.d("EGOV_JOB", "File path" + complaintFolderName + File.separator + listOfFiles[i].getName());

            if (listOfFiles[i].getName().startsWith("photo_")) {
                continue;
            }

            ImageView image = new ImageView(this);
            Bitmap bmp = _getBitmapImage(complaintFolderName + File.separator + listOfFiles[i].getName());
            image.setImageBitmap(bmp);
            image.setId(imageidx);
            imageidx = imageidx + 1;
            image.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent photo_viewer = new Intent(ComplaintDetailActivity.this, PhotoViewerActivity.class);
                    photo_viewer.putExtra("path", complaintFolderName);
                    photo_viewer.putExtra("complaintId", complaintId);
                    photo_viewer.putExtra("imageId", v.getId());
                    startActivity(photo_viewer);
                }
            });
            LinearLayout.LayoutParams inner_container_params = new LinearLayout.LayoutParams(_dpToPix(90),
                    _dpToPix(90));
            inner_container_params.setMargins(0, 0, 10, 0);
            image.setLayoutParams(inner_container_params);
            image.setPadding(2, 2, 2, 2);
            image.setBackgroundDrawable(getResources().getDrawable(R.drawable.edittext_border));
            image.setScaleType(ScaleType.CENTER_INSIDE);
            imageCntainer.addView(image);
        }
    }
}

From source file:co.mrktplaces.android.ui.views.smarttablayout.SmartTabLayout.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)}.//from  w w w . j a  v a  2s.c o m
 */
protected ImageView createDefaultTabView(int resource) {
    ImageView imageView = new ImageView(getContext());
    imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1));
    imageView.setImageResource(resource);
    if (tabViewBackgroundResId != NO_ID) {
        imageView.setBackgroundResource(tabViewBackgroundResId);
    } else 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);
        imageView.setBackgroundResource(outValue.resourceId);
    }

    imageView.setPadding(tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding, 0);

    if (tabViewTextMinWidth > 0) {
        imageView.setMinimumWidth(tabViewTextMinWidth);
    }

    return imageView;
}

From source file:cn.longchou.wholesale.activity.VehicleDetailActivity.java

private void getCarMaintenanceData() {
     HttpUtils http = new HttpUtils();
     String url = Constant.RequestMaintenance + cars.carID;
     http.send(HttpMethod.POST, url, new RequestCallBack<String>() {
         @Override//from www .  j a  v  a  2 s .c  o m
         public void onSuccess(ResponseInfo<String> responseInfo) {
             Gson gson = new Gson();
             MaintenanceReports json = gson.fromJson(responseInfo.result, MaintenanceReports.class);
             List<MaintenanceReports.MaintenanceReport> maintenanceReports = json.maintenanceReports;
             if (maintenanceReports != null) {
                 for (int i = 0; i < maintenanceReports.size(); i++) {
                     ImageView image = new ImageView(VehicleDetailActivity.this);
                     Glide.with(VehicleDetailActivity.this).load(maintenanceReports.get(i).imgUrl).into(image);
                     LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                             LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                     params.bottomMargin = 20;
                     image.setLayoutParams(params);
                     mLMaintenance.addView(image);
                 }
             }

         }

         @Override
         public void onFailure(HttpException e, String s) {

         }
     });
 }

From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java

/**
 * this function will initialize the ui showing the current image and reload
 * everything to make sure it is shown correctly
 *///w  w  w.  j  a va2 s  .  c  o  m
private void initUI() {
    // set the actionBar title and subtitle
    if (actionBar != null) {
        actionBar.setTitle(R.string.send_image);
        actionBar.setSubtitle(name);
        //      actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor
        //              (R.color.action_bar_transparent)));
        //      // set the statusBar color
        //      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        //        getActivity().getWindow().setStatusBarColor(getResources().getColor(R
        //                .color.action_bar_transparent));
    }

    // instantiate the ViewPager
    viewPager = (ViewPager) getActivity().findViewById(R.id.send_image_view_pager);
    viewPager.setAdapter(new MyPagerAdapter());
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            changePage(position, false, false);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });

    //Cancel button pressed
    getView().findViewById(R.id.send_image_cancel).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // just return to the chatFragment
            mListener.onReturnClick();
        }
    });
    //Send button pressed
    getView().findViewById(R.id.send_image_send).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // create the progressDialog that is to be shown while saving
            // the image
            ProgressDialog progressDialog = new ProgressDialog(getContext());
            if (images.size() > 1)
                progressDialog.setTitle(
                        String.format(getResources().getString(R.string.sending_images), images.size()));
            else
                progressDialog.setTitle(R.string.sending_image);
            // run the sendImage in a new thread because I am saving the
            // image and this should be done in a new thread
            new Thread(new SendImagesRunnable(new Handler(), getContext(), progressDialog)).start();
        }
    });

    // generate the overview only if there are at least 2 images
    if (images.size() > 1) {
        // the layoutParams for the imageView which has the following attributes:
        // width = height = 65dp
        // margin = 5dp
        getActivity().findViewById(R.id.send_image_overview).setVisibility(View.VISIBLE);
        int a = Constants.dipToPixel(getContext(), 65);
        RelativeLayout.LayoutParams imageViewParams = new RelativeLayout.LayoutParams(a, a);
        int b = Constants.dipToPixel(getContext(), 5);
        imageViewParams.setMargins(b, b, b, b);
        // the layoutParams for the backgroundView which has the following
        // attributes:
        // width = height = 71dp
        // margin = 2dp
        int c = Constants.dipToPixel(getContext(), 71);
        RelativeLayout.LayoutParams backgroundParams = new RelativeLayout.LayoutParams(c, c);
        int d = Constants.dipToPixel(getContext(), 2);
        backgroundParams.setMargins(d, d, d, d);
        // the layoutParams for the relativeLayout containing the image and
        // the background which has the following attributes:
        // width = height = wrap_content
        LinearLayout.LayoutParams relativeLayoutParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        LinearLayout linearLayout = (LinearLayout) getActivity().findViewById(R.id.send_image_overview_content);
        linearLayout.removeAllViewsInLayout();
        int i = 0;
        for (Message msg : images) {
            // set up the imageView
            ImageView imageView = new ImageView(getContext());
            imageView.setLayoutParams(imageViewParams);
            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
            // load the bitmap async
            AsyncDrawable.BitmapWorkerTask bitmapWorker = new AsyncDrawable.BitmapWorkerTask(imageView, a, a,
                    true);
            imageView.setImageDrawable(new AsyncDrawable(getResources(), null, bitmapWorker));
            imageView.setOnClickListener(new overviewSelectListener(i++));
            bitmapWorker.execute(FileUtils.getFile(getContext(), msg.getImageUri()));
            // set up the background
            View background = new View(getContext());
            background.setLayoutParams(backgroundParams);
            background.setBackgroundColor(getActivity().getResources().getColor(R.color.colorPrimaryDark));
            // make it invisible in the beginning
            background.setVisibility(View.GONE);

            // create the relativeLayout containing them
            RelativeLayout relativeLayout = new RelativeLayout(getContext());
            relativeLayout.setLayoutParams(relativeLayoutParams);
            relativeLayout.addView(background);
            relativeLayout.addView(imageView);
            // combination of Message and overviewViews
            msg.setLayout(relativeLayout);
            msg.setBackground(background);
            linearLayout.addView(relativeLayout);
        }
    } else
        getActivity().findViewById(R.id.send_image_overview).setVisibility(View.GONE);
    changePage(current, true, true);
    showSystemUI();
}

From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java

private void addRedDotTab(final int position, String title, int resId) {
    LinearLayout tabLayout = new LinearLayout(getContext());
    tabLayout.setOrientation(LinearLayout.HORIZONTAL);
    tabLayout.setGravity(Gravity.CENTER);
    TextView tab = new TextView(getContext());
    tab.setText(title);// w w  w .  j a va2s .  co m
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);

    tab.setSingleLine();
    tab.setTextColor(getResources().getColorStateList(R.color.pst_tab_text_selector));
    tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18.0f);
    tabLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != mOnPageClickedLisener) {
                mOnPageClickedLisener.onPageClicked(position);
            }
            pager.setCurrentItem(position);
        }
    });

    tabLayout.addView(tab, 0);
    ImageView tabImg = new ImageView(getContext());
    LinearLayout.LayoutParams tabImgParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    tabImgParams.setMargins(DeviceUtils.dip2px(getContext(), 5), DeviceUtils.dip2px(getContext(), 10), 0, 0);
    tabImgParams.gravity = Gravity.TOP;
    tabImg.setLayoutParams(tabImgParams);

    tabLayout.addView(tabImg, 1);
    tabsContainer.addView(tabLayout);
}

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

/**
 * Displays Callout//from   w w  w  .  jav a2  s . com
 * @param title the text to show in the Callout
 */
private void showCallout(String title) {

    // create a text view for the callout
    RelativeLayout calloutLayout = new RelativeLayout(getApplicationContext());

    TextView calloutContent = new TextView(getApplicationContext());
    calloutContent.setId(R.id.textview);
    calloutContent.setTextColor(Color.BLACK);
    calloutContent.setTextSize(18);
    calloutContent.setPadding(0, 10, 10, 0);

    calloutContent.setText(title);

    RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    relativeParams.addRule(RelativeLayout.RIGHT_OF, calloutContent.getId());

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

    calloutLayout.addView(calloutContent);
    calloutLayout.addView(imageView);

    mCallout.setLocation(mMapView.screenToLocation(mClickPoint));
    mCallout.setContent(calloutLayout);
    mCallout.show();
}

From source file:com.android.camera.v2.uimanager.SettingManager.java

private void initializeSettings() {
    if (mSettingLayout == null) {
        mSettingLayout = (ViewGroup) mActivity.getLayoutInflater().inflate(R.layout.setting_container_v2,
                mSettingViewLayer, false);
        mTabHost = (TabHost) mSettingLayout.findViewById(R.id.tab_title);
        mTabHost.setup();//from w w w  . jav a2  s.  c om
        String action = mIntent.getAction();
        LogHelper.i(TAG, "intent.action:" + action);
        List<Holder> list = new ArrayList<Holder>();
        // default setting
        int commonKeys[] = SettingKeys.SETTING_GROUP_COMMON_FOR_TAB;
        int cameraKeys[] = SettingKeys.SETTING_GROUP_CAMERA_FOR_TAB;
        int videoKeys[] = SettingKeys.SETTING_GROUP_VIDEO_FOR_TAB;

        if (FeatureSwitcher.isSubSettingEnabled()) {
            // For tablet
            commonKeys = SettingKeys.SETTING_GROUP_MAIN_COMMON_FOR_TAB;
        } else if (FeatureSwitcher.isLomoEffectEnabled()) {
            commonKeys = SettingKeys.SETTING_GROUP_COMMON_FOR_LOMOEFFECT;
        }
        // image capture setting, compared to default setting,
        // common settings and video setting may be different.
        if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)) {
            videoKeys = null;
        }
        // image capture setting, compared to default setting,
        // common settings and video setting
        // may be different.
        if (MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
            cameraKeys = null;
        }

        if (commonKeys != null) {
            list.add(new Holder(TAB_INDICATOR_KEY_COMMON, R.drawable.ic_tab_common_setting, commonKeys));
        }
        if (cameraKeys != null) {
            list.add(new Holder(TAB_INDICATOR_KEY_CAMERA, R.drawable.ic_tab_camera_setting, cameraKeys));
        }
        if (videoKeys != null) {
            list.add(new Holder(TAB_INDICATOR_KEY_VIDEO, R.drawable.ic_tab_video_setting, videoKeys));
        }

        int size = list.size();
        List<SettingListLayout> pageViews = new ArrayList<SettingListLayout>();
        for (int i = 0; i < size; i++) {
            Holder holder = list.get(i);
            // new page view
            SettingListLayout pageView = (SettingListLayout) mActivity.getLayoutInflater()
                    .inflate(R.layout.setting_list_layout_v2, mSettingViewLayer, false);
            ArrayList<ListPreference> listItems = new ArrayList<ListPreference>();
            pageView.setRootView(mSettingViewLayer);
            pageView.initialize(getListPreferences(holder.mSettingKeys, i == 0));
            pageView.setSettingChangedListener(SettingManager.this);
            pageViews.add(pageView);
            // new indicator view
            ImageView indicatorView = new ImageView(mActivity);
            if (indicatorView != null) {
                indicatorView.setBackgroundResource(R.drawable.bg_tab_title);
                indicatorView.setImageResource(holder.mIndicatorIconRes);
                indicatorView.setScaleType(ScaleType.CENTER);
            }
            mTabHost.addTab(mTabHost.newTabSpec(holder.mIndicatorKey).setIndicator(indicatorView)
                    .setContent(android.R.id.tabcontent));
        }

        mAdapter = new MyPagerAdapter(pageViews);
        mPager = (ViewPager) mSettingLayout.findViewById(R.id.pager);
        mPager.setAdapter(mAdapter);
        mPager.setOnPageChangeListener(mAdapter);
        mTabHost.setOnTabChangedListener(this);
    }
    int orientation = (Integer) mSettingViewLayer.getTag();
    CameraUtil.setOrientation(mSettingLayout, orientation, false);
}