Example usage for android.graphics Color TRANSPARENT

List of usage examples for android.graphics Color TRANSPARENT

Introduction

In this page you can find the example usage for android.graphics Color TRANSPARENT.

Prototype

int TRANSPARENT

To view the source code for android.graphics Color TRANSPARENT.

Click Source Link

Usage

From source file:com.nttec.everychan.ui.gallery.GalleryActivity.java

private void setWebView(final GalleryItemViewTag tag, final File file) {
    runOnUiThread(new Runnable() {
        private boolean oomFlag = false;

        private final ViewGroup.LayoutParams MATCH_PARAMS = new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        private void prepareWebView(WebView webView) {
            webView.setBackgroundColor(Color.TRANSPARENT);
            webView.setInitialScale(100);
            webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
                CompatibilityImpl.setScrollbarFadingEnabled(webView, true);
            }//  www  . j av  a 2  s.c o  m

            WebSettings settings = webView.getSettings();
            settings.setBuiltInZoomControls(true);
            settings.setSupportZoom(true);
            settings.setAllowFileAccess(true);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR_MR1) {
                CompatibilityImpl.setDefaultZoomFAR(settings);
                CompatibilityImpl.setLoadWithOverviewMode(settings, true);
            }
            settings.setUseWideViewPort(true);
            settings.setCacheMode(WebSettings.LOAD_NO_CACHE);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
                CompatibilityImpl.setBlockNetworkLoads(settings, true);
            }

            setScaleWebView(webView);
        }

        private void setScaleWebView(final WebView webView) {
            Runnable callSetScaleWebView = new Runnable() {
                @Override
                public void run() {
                    setPrivateScaleWebView(webView);
                }
            };

            Point resolution = new Point(tag.layout.getWidth(), tag.layout.getHeight());
            if (resolution.equals(0, 0)) {
                // wait until the view is measured and its size is known
                AppearanceUtils.callWhenLoaded(tag.layout, callSetScaleWebView);
            } else {
                callSetScaleWebView.run();
            }
        }

        private void setPrivateScaleWebView(WebView webView) {
            Point imageSize = getImageSize(file);
            Point resolution = new Point(tag.layout.getWidth(), tag.layout.getHeight());

            //Logger.d(TAG, "Resolution: "+resolution.x+"x"+resolution.y);
            double scaleX = (double) resolution.x / (double) imageSize.x;
            double scaleY = (double) resolution.y / (double) imageSize.y;
            int scale = (int) Math.round(Math.min(scaleX, scaleY) * 100d);
            scale = Math.max(scale, 1);
            //Logger.d(TAG, "Scale: "+(Math.min(scaleX, scaleY) * 100d));
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR_MR1) {
                double picdpi = (getResources().getDisplayMetrics().density * 160d) / scaleX;
                if (picdpi >= 240) {
                    CompatibilityImpl.setDefaultZoomFAR(webView.getSettings());
                } else if (picdpi <= 120) {
                    CompatibilityImpl.setDefaultZoomCLOSE(webView.getSettings());
                } else {
                    CompatibilityImpl.setDefaultZoomMEDIUM(webView.getSettings());
                }
            }

            webView.setInitialScale(scale);
            webView.setPadding(0, 0, 0, 0);
        }

        private Point getImageSize(File file) {
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeFile(file.getAbsolutePath(), options);
            return new Point(options.outWidth, options.outHeight);
        }

        private boolean useFallback(File file) {
            String path = file.getPath().toLowerCase(Locale.US);
            if (path.endsWith(".png"))
                return false;
            if (path.endsWith(".jpg"))
                return false;
            if (path.endsWith(".gif"))
                return false;
            if (path.endsWith(".jpeg"))
                return false;
            if (path.endsWith(".webp") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
                return false;
            return true;
        }

        @Override
        public void run() {
            try {
                recycleTag(tag, false);
                WebView webView = new WebViewFixed(GalleryActivity.this);
                webView.setLayoutParams(MATCH_PARAMS);
                tag.layout.addView(webView);
                if (settings.fallbackWebView() || useFallback(file)) {
                    prepareWebView(webView);
                    webView.loadUrl(Uri.fromFile(file).toString());
                } else {
                    JSWebView.setImage(webView, file);
                }
                tag.thumbnailView.setVisibility(View.GONE);
                tag.loadingView.setVisibility(View.GONE);
                tag.layout.setVisibility(View.VISIBLE);
            } catch (OutOfMemoryError oom) {
                System.gc();
                Logger.e(TAG, oom);
                if (!oomFlag) {
                    oomFlag = true;
                    run();
                } else
                    showError(tag, getString(R.string.error_out_of_memory));
            }
        }

    });
}

From source file:com.android.contacts.list.ContactListItemView.java

/**
 * Returns the {@link AppCompatImageButton} delete button, creating it if necessary.
 *///  w  w w.j  a v  a  2 s  .  c  o m
public AppCompatImageButton getDeleteImageButton(
        final MultiSelectEntryContactListAdapter.DeleteContactListener listener, final int position) {
    if (mDeleteImageButton == null) {
        mDeleteImageButton = new AppCompatImageButton(getContext());
        mDeleteImageButton.setImageResource(R.drawable.quantum_ic_cancel_vd_theme_24);
        mDeleteImageButton.setScaleType(ScaleType.CENTER);
        mDeleteImageButton.setBackgroundColor(Color.TRANSPARENT);
        mDeleteImageButton.setContentDescription(getResources().getString(R.string.description_delete_contact));
        if (CompatUtils.isLollipopCompatible()) {
            final TypedValue typedValue = new TypedValue();
            getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackgroundBorderless,
                    typedValue, true);
            mDeleteImageButton.setBackgroundResource(typedValue.resourceId);
        }
        addView(mDeleteImageButton);
    }
    // Reset onClickListener because after reloading the view, position might be changed.
    mDeleteImageButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // Inform the adapter that delete icon was clicked.
            if (listener != null) {
                listener.onContactDeleteClicked(position);
            }
        }
    });
    return mDeleteImageButton;
}

From source file:com.VVTeam.ManHood.Fragment.HistogramFragment.java

private void updateRangeSwitch() {
    //       worldRelative.setSelected(false);
    //       areaRelative.setSelected(false);
    //        hoodRelative.setSelected(false);
    worldRelative.setBackgroundColor(Color.TRANSPARENT);
    areaRelative.setBackgroundColor(Color.TRANSPARENT);
    hoodRelative.setBackgroundColor(Color.TRANSPARENT);

    if (selectedRange == SliceRange.SliceRangeAll) {
        //           worldRelative.setSelected(true);
        worldRelative.setBackgroundResource(R.drawable.cell_p);
    } else if (selectedRange == SliceRange.SliceRange200) {
        //           areaRelative.setSelected(true);
        areaRelative.setBackgroundResource(R.drawable.cell_p);
    } else if (selectedRange == SliceRange.SliceRange20) {
        //           hoodRelative.setSelected(true);
        hoodRelative.setBackgroundResource(R.drawable.cell_p);
    }/* ww w  .  ja v  a2  s  .  c  o  m*/
}

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

private void setLocalDirBtnListener() {
    CustomSpinnerAdapter adapter = new CustomSpinnerAdapter(this, R.layout.custom_simple_spinner_item);
    //        adapter.setTextColor(Color.BLACK);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    localFileListDirSpinner.setPrompt("??");
    localFileListDirSpinner.setAdapter(adapter);

    int a_no = 0;
    List<ProfileListItem> pl = createLocalProfileEntry();
    for (int i = 0; i < pl.size(); i++) {
        adapter.add(pl.get(i).getName());
        if (pl.get(i).getName().equals(localBase))
            localFileListDirSpinner.setSelection(a_no);
        a_no++;//from w w w  .  j  av a  2 s  . c  o m
    }
    localFileListDirSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (mIgnoreSpinnerSelection)
                return;
            Spinner spinner = (Spinner) parent;
            String turl = (String) spinner.getSelectedItem();
            if (turl.equals(localBase))
                tabHost.setCurrentTabByTag(SMBEXPLORER_TAB_LOCAL);
            else {
                localDir = "";
                localBase = turl;

                clearDirHist(localDirHist);
                //               putDirHist(localBase, localDir, localDirHist);

                localCurrFLI.pos_fv = localFileListView.getFirstVisiblePosition();
                if (localFileListView.getChildAt(0) != null)
                    localCurrFLI.pos_top = localFileListView.getChildAt(0).getTop();

                loadLocalFilelist(localBase, localDir);
                localFileListView.setSelection(0);
                for (int j = 0; j < localFileListView.getChildCount(); j++)
                    localFileListView.getChildAt(j).setBackgroundColor(Color.TRANSPARENT);
                setEmptyFolderView();
            }
        }

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

    localFileListPathBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (localFileListCache.size() > 0)
                showFileListCache(localFileListCache, localFileListAdapter, localFileListView,
                        localFileListDirSpinner);
        }
    });

    localFileListUpBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            processLocalUpButton();
        }
    });

    localFileListTopBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            processLocalTopButton();
        }
    });

    localFileListPasteBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            String to_dir = "";
            if (localDir.equals(""))
                to_dir = localBase;
            else
                to_dir = localBase + "/" + localDir;
            pasteItem(localFileListAdapter, to_dir, localBase);
        }
    });
    localFileListReloadBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            setLocalDirBtnListener();
            reloadFilelistView();
            setEmptyFolderView();
        }
    });
    localFileListCreateBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) {
                if (localDir.length() == 0)
                    createItem(localFileListAdapter, "C", localBase);
                else
                    createItem(localFileListAdapter, "C", localBase + "/" + localDir);
            } else if (currentTabName.equals(SMBEXPLORER_TAB_REMOTE)) {
                if (remoteDir.length() == 0)
                    createItem(remoteFileListAdapter, "C", remoteBase);
                else
                    createItem(remoteFileListAdapter, "C", remoteBase + "/" + remoteDir);
            }
        }
    });

}

From source file:com.skytree.epubtest.BookViewActivity.java

public void makeNoteBox() {
    RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); // width,height
    noteBox = new SkyBox(this);
    noteBox.setBoxColor(currentColor);//from  w  w  w. j a  v  a 2s . c  om
    noteBox.setArrowHeight(ps(25));
    noteBox.setArrowDirection(false);
    param.leftMargin = ps(50);
    param.topMargin = ps(400);
    int minWidth = Math.min(this.getWidth(), this.getHeight());
    noteBoxWidth = (int) (minWidth * 0.8);
    param.width = noteBoxWidth;
    param.height = ps(300);
    noteBox.setLayoutParams(param);
    noteBox.setArrowDirection(false);

    noteEditor = new EditText(this);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); // width,height
    params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT); // width,height
    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.FILL_PARENT;
    noteEditor.setLayoutParams(params);
    noteEditor.setBackgroundColor(Color.TRANSPARENT);
    noteEditor.setMaxLines(1000);
    noteEditor.setGravity(Gravity.TOP | Gravity.LEFT);
    noteEditor.setOnFocusChangeListener(focusListener);
    noteBox.contentView.addView(noteEditor);

    ePubView.addView(noteBox);
    this.hideNoteBox();
}

From source file:com.androzic.MapActivity.java

protected void dimScreen(Location location) {
    int color = Color.TRANSPARENT;
    Calendar now = GregorianCalendar.getInstance(TimeZone.getDefault());
    if (autoDim && !Astro.isDaytime(application.getZenith(), location, now))
        color = dimValue << 57; // value * 2 and shifted to transparency octet
    dimView.setBackgroundColor(color);/*  w ww . ja v a  2s  .  c  om*/
}

From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java

private void showFileListCache(final ArrayList<FileListCacheItem> fcl, final FileListAdapter fla,
        final ListView flv, final Spinner spinner) {
    // ??//from w  w w .  ja  v  a  2 s .  c o  m
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setContentView(R.layout.select_file_cache_dlg);
    //      final Button btnOk = 
    //            (Button) dialog.findViewById(R.id.select_file_cache_dlg_ok);
    final Button btnCancel = (Button) dialog.findViewById(R.id.select_file_cache_dlg_cancel);

    CommonDialog.setDlgBoxSizeCompact(dialog);

    ((TextView) dialog.findViewById(R.id.select_file_cache_dlg_title)).setText("Select file cache");

    ListView lv = (ListView) dialog.findViewById(R.id.select_file_cache_dlg_listview);

    final ArrayList<String> list = new ArrayList<String>();
    for (int i = 0; i < fcl.size(); i++) {
        list.add(fcl.get(i).directory);
    }
    Collections.sort(list, new Comparator<String>() {
        @Override
        public int compare(String lhs, String rhs) {
            return lhs.compareToIgnoreCase(rhs);
        }
    });
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, R.layout.simple_list_item_1o, list);
    lv.setAdapter(adapter);

    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String t_dir = list.get(position);
            FileListCacheItem dhi = getFileListCache(t_dir, fcl);
            if (dhi != null) {
                mIgnoreSpinnerSelection = true;
                int s_no = -1;
                for (int i = 0; i < spinner.getCount(); i++) {
                    if (spinner.getItemAtPosition(i).toString().equals(dhi.profile_name)) {
                        s_no = i;
                        break;
                    }
                }
                fla.setDataList(dhi.file_list);
                fla.notifyDataSetChanged();
                if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) {
                    localBase = dhi.base;
                    if (dhi.base.equals(dhi.directory))
                        localDir = "";
                    else
                        localDir = dhi.directory.replace(localBase + "/", "");
                    replaceDirHist(localDirHist, dhi.directory_history);
                    setFilelistCurrDir(localFileListDirSpinner, localBase, localDir);
                    setFileListPathName(localFileListPathBtn, localFileListCache, localBase, localDir);
                    setEmptyFolderView();
                    localCurrFLI = dhi;
                    flv.setSelection(0);
                    for (int j = 0; j < localFileListView.getChildCount(); j++)
                        localFileListView.getChildAt(j).setBackgroundColor(Color.TRANSPARENT);
                    localFileListReloadBtn.performClick();
                } else if (currentTabName.equals(SMBEXPLORER_TAB_REMOTE)) {
                    remoteBase = dhi.base;
                    if (dhi.base.equals(dhi.directory))
                        remoteDir = "";
                    else
                        remoteDir = dhi.directory.replace(remoteBase + "/", "");
                    replaceDirHist(remoteDirHist, dhi.directory_history);
                    setFilelistCurrDir(remoteFileListDirSpinner, remoteBase, remoteDir);
                    setFileListPathName(remoteFileListPathBtn, remoteFileListCache, remoteBase, remoteDir);
                    setEmptyFolderView();
                    remoteCurrFLI = dhi;
                    flv.setSelection(0);

                    //                  Log.v("","base="+remoteBase+", dir="+remoteDir+", histsz="+remoteDirHist.size());
                    for (int j = 0; j < remoteFileListView.getChildCount(); j++)
                        remoteFileListView.getChildAt(j).setBackgroundColor(Color.TRANSPARENT);
                    if (remoteDir.equals("")) {
                        remoteFileListTopBtn.setEnabled(false);
                        remoteFileListUpBtn.setEnabled(false);
                    } else {
                        remoteFileListTopBtn.setEnabled(true);
                        remoteFileListUpBtn.setEnabled(true);
                    }
                }

                if (s_no != -1)
                    spinner.setSelection(s_no);
                Handler hndl = new Handler();
                hndl.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mIgnoreSpinnerSelection = false;
                    }
                }, 100);
                dialog.dismiss();
            }
        }
    });

    btnCancel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });

    dialog.show();

}

From source file:com.FluksoViz.FluksoVizActivity.java

private void make_graph_pretty(XYPlot p) {

    p.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 56); // Reduce the number
    // of range labels
    // Plot1.setTicksPerDomainLabel(1);
    p.setDomainValueFormat(new DateFormat_p1());

    p.setRangeStep(XYStepMode.SUBDIVIDE, 5);// Skala Y pionowa
    // Plot1.setRangeStep(XYStepMode.INCREMENT_BY_VAL, 1);
    // Plot1.setTicksPerRangeLabel(1);
    p.getTitleWidget().setClippingEnabled(false);

    p.getTitleWidget().pack();//from   w  w w.  j  a  va 2 s .c o m
    int axis_font_size = 15;
    int title_font_size = 15;
    int domain_font_size = 12;

    if (screen_width == 320) {
        axis_font_size = 12;
        title_font_size = 9;
        domain_font_size = 10;
    }

    p.getTitleWidget().getLabelPaint().setTextSize(title_font_size);
    p.getGraphWidget().getDomainLabelPaint().setTextSize(domain_font_size);
    p.getGraphWidget().getDomainLabelPaint().setColor(Color.WHITE);
    p.getGraphWidget().getRangeLabelPaint().setColor(Color.WHITE);
    p.getGraphWidget().getRangeLabelPaint().setTextSize(axis_font_size);
    p.getGraphWidget().getDomainOriginLabelPaint().setTextSize(domain_font_size);
    p.getGraphWidget().getRangeOriginLabelPaint().setTextSize(axis_font_size);
    p.getGraphWidget().setClippingEnabled(false);

    p.setDomainValueFormat(new DecimalFormat("#"));

    p.getLegendWidget().setVisible(false);
    p.getDomainLabelWidget().setVisible(false);
    p.getRangeLabelWidget().setVisible(false);
    p.getGraphWidget().getGridLinePaint().setPathEffect(new DashPathEffect(new float[] { 1, 2, 1, 2 }, 0));
    p.getBackgroundPaint().setColor(Color.TRANSPARENT);
    p.getGraphWidget().getBackgroundPaint().setColor(Color.TRANSPARENT);
    p.getGraphWidget().getGridBackgroundPaint().setColor(Color.TRANSPARENT);
    p.setGridPadding(0, 10, 0, 0); // left top right bottom
    p.getGraphWidget().getGridLinePaint().setColor(Color.TRANSPARENT);

    if (sensor_number != 4) {
        p.setRangeLowerBoundary(0, BoundaryMode.GROW);// to ustawia
    }

    if (sensor_number == 4) {
        p.addMarker(new YValueMarker(0, "0", new XPositionMetric(-11, XLayoutStyle.ABSOLUTE_FROM_LEFT),
                Color.WHITE, Color.WHITE));
        p.setRangeStep(XYStepMode.SUBDIVIDE, 2);
        p.getGraphWidget().getRangeOriginLinePaint().setAlpha(0);

        series1mFormat = new LineAndPointFormatter( // FAZA
                Color.rgb(0, 220, 0), // line color
                Color.rgb(0, 150, 0), // point color
                null);

        line1mFill.setShader(
                new LinearGradient(0, 0, 0, 200, Color.rgb(0, 200, 0), Color.BLACK, Shader.TileMode.MIRROR));
        series1mFormat.getLinePaint().setStrokeWidth(4);
        series1mFormat.setFillPaint(line1mFill);

        series2mFormat = new LineAndPointFormatter( // faza 2 solar
                Color.rgb(200, 200, 0), // line
                Color.rgb(100, 100, 0), // point color
                null);
        line2mFill.setShader(
                new LinearGradient(0, 150, 0, 120, Color.rgb(250, 250, 0), Color.BLACK, Shader.TileMode.CLAMP));
        series2mFormat.setFillDirection(FillDirection.TOP);
        series2mFormat.setFillPaint(line2mFill);
        series2mFormat.getLinePaint().setStrokeWidth(5);

        series3mFormat = new LineAndPointFormatter( // FAZA 3 formater
                Color.rgb(0, 220, 0), // line color
                Color.rgb(0, 150, 0), // point color
                null);
        line3mFill.setAlpha(255);
        line3mFill.setShader(new LinearGradient(0, 0, 0, 50, Color.BLACK, Color.BLACK, Shader.TileMode.MIRROR));
        series3mFormat.getLinePaint().setStrokeWidth(7);
        series3mFormat.setFillPaint(line3mFill);

        series4mFormat = new LineAndPointFormatter(Color.rgb(0, 140, 220), // line
                Color.rgb(0, 120, 190), // point color
                null);
        line4mFill = new Paint();
        line4mFill.setAlpha(190);
        line4mFill.setShader(new LinearGradient(0, 0, 0, 50, Color.BLACK, Color.BLACK, Shader.TileMode.MIRROR));
        series4mFormat.getLinePaint().setStrokeWidth(5);
        series4mFormat.setFillPaint(line4mFill);
        series4mFormat.setFillDirection(FillDirection.TOP);

        // XYRegionFormatter region4Formatter = new
        // XYRegionFormatter(Color.BLUE);
        // series4mFormat.addRegion(new RectRegion(Double.NEGATIVE_INFINITY,
        // Double.POSITIVE_INFINITY, 0, -1000, "R1"), region4Formatter);

    }

    // p.setRangeLowerBoundary(0, BoundaryMode.GROW);// to ustawia
    // min i max
    // Plot1.setRangeUpperBoundary(11, BoundaryMode.FIXED);

    p.setRangeValueFormat(new DecimalFormat("#"));
    p.setBorderStyle(Plot.BorderStyle.SQUARE, null, null);
    p.setBorderPaint(null);
    p.disableAllMarkup(); // To get rid of them call disableAllMarkup():

}

From source file:com.haomee.chat.activity.ChatActivity.java

/**
 * ?/*from   w w  w  . j a  v a2  s  .co  m*/
 */
private View inflateYanWenZi(int current_page, List<String> list) {

    View view = LayoutInflater.from(this).inflate(R.layout.yanwenzi_grid, null);
    GridView grid = (GridView) view.findViewById(R.id.gridView1);
    grid.setSelector(new ColorDrawable(Color.TRANSPARENT));

    final NewYanWenZiAdapter new_express_adapter = new NewYanWenZiAdapter(ChatActivity.this);
    grid.setAdapter(new_express_adapter);

    int total_page = (list.size() - 1) / 12 + 1;
    if (current_page < total_page - 1) {
        new_express_adapter.setData(list.subList(current_page * 12, (current_page + 1) * 12));
    } else {
        new_express_adapter.setData(list.subList(current_page * 12, list.size()));
    }

    grid.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            String wenzi = new_express_adapter.getData().get(position);

            if (!mEditTextContent.getText().toString().equals("")) {
                mEditTextContent.setText(mEditTextContent.getText().toString() + wenzi);
            } else {
                mEditTextContent.setText(wenzi);
            }
            mEditTextContent.setSelection(mEditTextContent.getText().toString().length());
        }
    });

    return view;
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static int getAccountColor(final Context context, final long account_id) {
    if (context == null)
        return Color.TRANSPARENT;
    final Integer cached = sAccountColors.get(account_id);
    if (cached != null)
        return cached;
    final Cursor cur = ContentResolverUtils.query(context.getContentResolver(), Accounts.CONTENT_URI,
            new String[] { Accounts.COLOR }, Accounts.ACCOUNT_ID + " = " + account_id, null, null);
    if (cur == null)
        return Color.TRANSPARENT;
    try {//from   w w w.j av a 2s  .c  o  m
        if (cur.getCount() > 0 && cur.moveToFirst()) {
            final int color = cur.getInt(0);
            sAccountColors.put(account_id, color);
            return color;
        }
        return Color.TRANSPARENT;
    } finally {
        cur.close();
    }
}