Example usage for android.graphics Typeface ITALIC

List of usage examples for android.graphics Typeface ITALIC

Introduction

In this page you can find the example usage for android.graphics Typeface ITALIC.

Prototype

int ITALIC

To view the source code for android.graphics Typeface ITALIC.

Click Source Link

Usage

From source file:org.anoopam.main.anoopamvideo.VideoListActivity.java

@Override
public void manageAppBar(ActionBar actionBar, Toolbar toolbar, ActionBarDrawerToggle actionBarDrawerToggle) {

    actionBar.setDisplayHomeAsUpEnabled(true);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override/* w  w w. j av  a  2  s  .c o  m*/
        public void onClick(View v) {
            finish();
        }
    });
    toolbar.setTitle(getString(R.string.nav_video));
    SpannableString spannableString = new SpannableString(currentAlbumName);
    spannableString.setSpan(new StyleSpan(Typeface.ITALIC), 0, spannableString.length(), 0);
    toolbar.setSubtitle(spannableString);
}

From source file:edu.sfsu.cs.orange.ocr.language.TranslateAsyncTask.java

@Override
protected synchronized void onPostExecute(Boolean result) {
    super.onPostExecute(result);

    if (result) {
        //Log.i(TAG, "SUCCESS");
        if (targetLanguageTextView != null) {
            targetLanguageTextView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL), Typeface.NORMAL);
        }/*from  w  ww  .  j  a  v  a2 s  . c  o m*/
        textView.setText(translatedText);
        textView.setVisibility(View.VISIBLE);
        textView.setTextColor(activity.getResources().getColor(R.color.translation_text));

        // Crudely scale betweeen 22 and 32 -- bigger font for shorter text
        int scaledSize = Math.max(22, 32 - translatedText.length() / 4);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize);

    } else {
        Log.e(TAG, "FAILURE");
        targetLanguageTextView.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC), Typeface.ITALIC);
        targetLanguageTextView.setText("Unavailable");

    }

    // Turn off the indeterminate progress indicator
    if (progressView != null) {
        progressView.setVisibility(View.GONE);
    }
}

From source file:org.anoopam.main.anoopamvideo.VideoCatListActivity.java

@Override
public void manageAppBar(ActionBar actionBar, Toolbar toolbar, ActionBarDrawerToggle actionBarDrawerToggle) {
    actionBar.setDisplayHomeAsUpEnabled(true);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override//from ww w  . j  a  v  a  2  s . c  o  m
        public void onClick(View v) {

            handleBackPress();

        }
    });
    toolbar.setTitle(getString(R.string.nav_video_title));
    SpannableString spannableString = new SpannableString(albumName);
    spannableString.setSpan(new StyleSpan(Typeface.ITALIC), 0, spannableString.length(), 0);
    toolbar.setSubtitle(spannableString);
}

From source file:com.tr4android.support.extension.typeface.TypefaceCompat.java

/**
 * Creates a typeface object that best matches the specified typeface and the specified style.
 * Use this call if you want to pick a new style from the same family of an typeface object.
 * If family is null, this selects from the default font's family.
 *
 * @param ctx        A context./*w w w  .  ja  v  a 2 s.com*/
 * @param familyName May be null. The name of the font family.
 * @param style      The style (normal, bold, italic) of the typeface, e.g. NORMAL, BOLD, ITALIC, BOLD_ITALIC.
 * @return The best matching typeface.
 * @since 0.1.1
 * @deprecated
 */
@Deprecated
public static Typeface create(Context ctx, String familyName, int style) {
    if (!mInitialized)
        initialize();
    if (isSupported(familyName) || familyName == null) {
        boolean styleAfterwards = false;
        String fileName = FONT_FAMILY_FILE_PREFIX.get(familyName == null ? "sans-serif" : familyName);
        if (fileName.endsWith("-")) {
            // All styles are supported.
            fileName += STYLE_SUFFIX[style];
        } else {
            switch (style) {
            case Typeface.NORMAL:
                break;
            case Typeface.BOLD:
            case Typeface.BOLD_ITALIC:
                // These styles are not supported by default. Therefore force style after retrieving normal font.
                styleAfterwards = true;
                break;
            case Typeface.ITALIC:
                fileName += STYLE_SUFFIX[style];
                break;
            }
        }
        fileName += TTF_SUFFIX;
        // Retrieve Typeface from cache.
        Typeface tf = TYPEFACE_CACHE.get(fileName);
        if (tf == null) {
            // Create Typeface and cache it for later.
            String fontPath = "fonts/" + fileName;
            tf = Typeface.createFromAsset(ctx.getAssets(), fontPath);
            if (tf != null) {
                TYPEFACE_CACHE.put(fileName, tf);
            }
        }
        if (tf != null) {
            return styleAfterwards ? Typeface.create(tf, style) : tf;
        }
    }
    // Let the default implementation of Typeface try.
    return Typeface.create(familyName, style);
}

From source file:com.google.android.gcm.demo.ui.TopicsFragment.java

@Override
public void refresh() {
    float density = getActivity().getResources().getDisplayMetrics().density;
    SimpleArrayMap<String, Sender> addressBook = mSenders.getSenders();
    LinearLayout sendersList = new LinearLayout(getActivity());
    sendersList.setOrientation(LinearLayout.VERTICAL);
    for (int i = 0; i < addressBook.size(); i++) {
        Sender sender = addressBook.valueAt(i);
        // Check if at least a topic is subscribed for this sender
        int subscribedTopics = 0;
        for (Boolean subscribed : sender.topics.values()) {
            if (subscribed) {
                subscribedTopics++;//w w w  .j a  va2  s  .  co m
            }
        }
        if (subscribedTopics > 0) {
            LinearLayout senderRow = (LinearLayout) getActivity().getLayoutInflater()
                    .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
            ImageView senderIcon = (ImageView) senderRow.findViewById(R.id.widget_itbr_icon);
            TextView senderLabel = (TextView) senderRow.findViewById(R.id.widget_itbr_text);
            senderRow.findViewById(R.id.widget_itbr_button).setVisibility(View.GONE);
            senderIcon.setImageResource(R.drawable.cloud_googblue);
            senderIcon.setPadding(0, 0, (int) (8 * density), 0);
            senderLabel.setText(getString(R.string.topics_sender_id, sender.senderId));
            sendersList.addView(senderRow);
            for (Map.Entry<String, Boolean> topic : sender.topics.entrySet()) {
                if (topic.getValue()) {
                    LinearLayout row = (LinearLayout) getActivity().getLayoutInflater()
                            .inflate(R.layout.widget_icon_text_button_row, sendersList, false);
                    ImageView icon = (ImageView) row.findViewById(R.id.widget_itbr_icon);
                    TextView label = (TextView) row.findViewById(R.id.widget_itbr_text);
                    Button button = (Button) row.findViewById(R.id.widget_itbr_button);
                    icon.setImageResource(R.drawable.bigtop_updates_grey600);
                    label.setText(topic.getKey());
                    button.setText(R.string.topics_unsubscribe);
                    button.setTag(R.id.tag_action, ACTION_UNSUBSCRIBE);
                    button.setTag(R.id.tag_senderid, sender.senderId);
                    button.setTag(R.id.tag_topic, topic.getKey());
                    button.setOnClickListener(this);
                    row.setPadding((int) (16 * density), 0, 0, 0);
                    sendersList.addView(row);
                }
            }
        }
    }
    if (sendersList.getChildCount() == 0) {
        TextView noTokens = new TextView(getActivity());
        noTokens.setText(getString(R.string.topics_no_topic_subscribed));
        noTokens.setTypeface(null, Typeface.ITALIC);
        sendersList.addView(noTokens);
    }
    FrameLayout topicsView = (FrameLayout) getActivity().findViewById(R.id.topics_list_wrapper);
    topicsView.removeAllViews();
    topicsView.addView(sendersList);
}

From source file:net.toload.main.hd.ui.ShareDialog.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle) {

    getDialog().getWindow().setTitle(getResources().getString(R.string.share_dialog_title));
    datasource = new LimeDB(getActivity());
    sharedialog = this;

    activity = getActivity();/*w w  w . ja  v a  2s  .  c  o  m*/
    view = inflater.inflate(R.layout.fragment_dialog_share, container, false);

    btnShareCustom = (Button) view.findViewById(R.id.btnShareCustom);
    btnShareArray = (Button) view.findViewById(R.id.btnShareArray);
    btnShareArray10 = (Button) view.findViewById(R.id.btnShareArray10);
    btnShareCj = (Button) view.findViewById(R.id.btnShareCj);
    btnShareCj5 = (Button) view.findViewById(R.id.btnShareCj5);
    btnShareDayi = (Button) view.findViewById(R.id.btnShareDayi);
    btnShareEcj = (Button) view.findViewById(R.id.btnShareEcj);
    btnShareEz = (Button) view.findViewById(R.id.btnShareEz);
    btnSharePhonetic = (Button) view.findViewById(R.id.btnSharePhonetic);
    btnSharePinyin = (Button) view.findViewById(R.id.btnSharePinyin);
    btnShareScj = (Button) view.findViewById(R.id.btnShareScj);
    btnShareWb = (Button) view.findViewById(R.id.btnShareWb);
    btnShareHs = (Button) view.findViewById(R.id.btnShareHs);

    btnShareRelated = (Button) view.findViewById(R.id.btnShareRelated);

    btnShareCancel = (Button) view.findViewById(R.id.btnShareCancel);
    btnShareCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });

    HashMap<String, String> check = new HashMap<String, String>();

    List<Im> imlist = datasource.getIm(null, Lime.IM_TYPE_NAME);
    for (int i = 0; i < imlist.size(); i++) {
        check.put(imlist.get(i).getCode(), imlist.get(i).getDesc());
    }

    if (check.get(Lime.DB_TABLE_CUSTOM) == null) {
        btnShareCustom.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnShareCustom.setTypeface(null, Typeface.ITALIC);
        btnShareCustom.setEnabled(false);
    } else {
        btnShareCustom.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnShareCustom.setTypeface(null, Typeface.BOLD);

        btnShareCustom.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_CUSTOM);
            }
        });
    }

    if (check.get(Lime.DB_TABLE_PHONETIC) == null) {
        btnSharePhonetic.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnSharePhonetic.setTypeface(null, Typeface.ITALIC);
        btnSharePhonetic.setEnabled(false);
    } else {
        btnSharePhonetic.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnSharePhonetic.setTypeface(null, Typeface.BOLD);

        btnSharePhonetic.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_PHONETIC);
            }
        });
    }

    if (check.get(Lime.DB_TABLE_CJ) == null) {
        btnShareCj.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnShareCj.setTypeface(null, Typeface.ITALIC);
        btnShareCj.setEnabled(false);
    } else {
        btnShareCj.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnShareCj.setTypeface(null, Typeface.BOLD);

        btnShareCj.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_CJ);
            }
        });
    }

    if (check.get(Lime.DB_TABLE_CJ5) == null) {
        btnShareCj5.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnShareCj5.setTypeface(null, Typeface.ITALIC);
        btnShareCj5.setEnabled(false);
    } else {
        btnShareCj5.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnShareCj5.setTypeface(null, Typeface.BOLD);

        btnShareCj5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_CJ5);
            }
        });
    }

    if (check.get(Lime.DB_TABLE_SCJ) == null) {
        btnShareScj.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnShareScj.setTypeface(null, Typeface.ITALIC);
        btnShareScj.setEnabled(false);
    } else {
        btnShareScj.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnShareScj.setTypeface(null, Typeface.BOLD);
        btnShareScj.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_SCJ);
            }
        });
    }

    if (check.get(Lime.DB_TABLE_ECJ) == null) {
        btnShareEcj.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnShareEcj.setTypeface(null, Typeface.ITALIC);
        btnShareEcj.setEnabled(false);
    } else {
        btnShareEcj.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnShareEcj.setTypeface(null, Typeface.BOLD);

        btnShareEcj.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_ECJ);
            }
        });
    }

    if (check.get(Lime.DB_TABLE_DAYI) == null) {
        btnShareDayi.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnShareDayi.setTypeface(null, Typeface.ITALIC);
        btnShareDayi.setEnabled(false);
    } else {
        btnShareDayi.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnShareDayi.setTypeface(null, Typeface.BOLD);

        btnShareDayi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_DAYI);
            }
        });
    }

    if (check.get(Lime.DB_TABLE_EZ) == null) {
        btnShareEz.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnShareEz.setTypeface(null, Typeface.ITALIC);
        btnShareEz.setEnabled(false);
    } else {
        btnShareEz.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnShareEz.setTypeface(null, Typeface.BOLD);

        btnShareEz.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_EZ);
            }
        });
    }

    if (check.get(Lime.DB_TABLE_ARRAY) == null) {
        btnShareArray.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnShareArray.setTypeface(null, Typeface.ITALIC);
        btnShareArray.setEnabled(false);
    } else {
        btnShareArray.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnShareArray.setTypeface(null, Typeface.BOLD);

        btnShareArray.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_ARRAY);
            }
        });
    }

    if (check.get(Lime.DB_TABLE_ARRAY10) == null) {
        btnShareArray10.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnShareArray10.setTypeface(null, Typeface.ITALIC);
        btnShareArray10.setEnabled(false);
    } else {
        btnShareArray10.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnShareArray10.setTypeface(null, Typeface.BOLD);

        btnShareArray10.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_ARRAY10);
            }
        });
    }

    if (check.get(Lime.DB_TABLE_HS) == null) {
        btnShareHs.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnShareHs.setTypeface(null, Typeface.ITALIC);
        btnShareHs.setEnabled(false);
    } else {
        btnShareHs.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnShareHs.setTypeface(null, Typeface.BOLD);

        btnShareHs.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_HS);
            }
        });
    }

    if (check.get(Lime.DB_TABLE_WB) == null) {
        btnShareWb.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnShareWb.setTypeface(null, Typeface.ITALIC);
        btnShareWb.setEnabled(false);
    } else {
        btnShareWb.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnShareWb.setTypeface(null, Typeface.BOLD);

        btnShareWb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_WB);
            }
        });
    }

    if (check.get(Lime.DB_TABLE_PINYIN) == null) {
        btnSharePinyin.setAlpha(Lime.HALF_ALPHA_VALUE);
        btnSharePinyin.setTypeface(null, Typeface.ITALIC);
        btnSharePinyin.setEnabled(false);
    } else {
        btnSharePinyin.setAlpha(Lime.NORMAL_ALPHA_VALUE);
        btnSharePinyin.setTypeface(null, Typeface.BOLD);

        btnSharePinyin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                confirmShareDialog(Lime.IM_PINYIN);
            }
        });
    }

    btnShareRelated.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            confirmShareDialog(Lime.DB_RELATED);
        }
    });

    return view;
}

From source file:color.kidpaint.com.kidpaintcolor.tools.implementation.TextTool.java

public void updateTypeface() {
    int style;// ww w  .  j ava 2  s  . c o m
    if (mItalic) {
        style = Typeface.ITALIC;
    } else {
        style = Typeface.NORMAL;
    }

    if (mFont.equals("Sans Serif")) {
        mTextPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, style));
    } else if (mFont.equals("Serif")) {
        mTextPaint.setTypeface(Typeface.create(Typeface.SERIF, style));
    } else if (mFont.equals("Monospace")) {
        mTextPaint.setTypeface(Typeface.create(Typeface.MONOSPACE, style));
    }

    if (Build.VERSION.SDK_INT < 21) {
        mTextPaint.setTextSkewX(0.0f);
        if (mFont.equals("Monospace")) {
            mTextPaint.setTypeface(Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL));
            if (style == Typeface.ITALIC) {
                mTextPaint.setTextSkewX(-0.25f);
            }
        }
    }
}

From source file:com.morlunk.mumbleclient.channel.ChannelListAdapter.java

@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
    final Node node = mNodes.get(position);
    if (node.isChannel()) {
        final IChannel channel = node.getChannel();
        final ChannelViewHolder cvh = (ChannelViewHolder) viewHolder;
        cvh.itemView.setOnClickListener(new View.OnClickListener() {
            @Override/*w w w .j  av  a2s.c  o  m*/
            public void onClick(View v) {
                if (mChannelClickListener != null) {
                    mChannelClickListener.onChannelClick(channel);
                }
            }
        });

        final boolean expandUsable = channel.getSubchannels().size() > 0
                || channel.getSubchannelUserCount() > 0;
        cvh.mChannelExpandToggle.setImageResource(
                node.isExpanded() ? R.drawable.ic_action_expanded : R.drawable.ic_action_collapsed);
        cvh.mChannelExpandToggle.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mExpandedChannels.put(channel.getId(), !node.isExpanded());
                updateChannels(); // FIXME: very inefficient.
                notifyDataSetChanged();
            }
        });
        // Dim channel expand toggle when no subchannels exist
        cvh.mChannelExpandToggle.setEnabled(expandUsable);
        cvh.mChannelExpandToggle.setVisibility(expandUsable ? View.VISIBLE : View.INVISIBLE);

        cvh.mChannelName.setText(channel.getName());

        int nameTypeface = Typeface.NORMAL;
        if (mService != null && mService.getConnectionState() == JumbleService.ConnectionState.CONNECTED) {
            if (channel.equals(mService.getSessionChannel())) {
                nameTypeface |= Typeface.BOLD;
                // Always italicize our current channel if it has a link.
                if (channel.getLinks().size() > 0) {
                    nameTypeface |= Typeface.ITALIC;
                }
            }
            // Italicize channels in a link with our current channel.
            if (channel.getLinks().contains(mService.getSessionChannel())) {
                nameTypeface |= Typeface.ITALIC;
            }
        }
        cvh.mChannelName.setTypeface(null, nameTypeface);

        if (mShowChannelUserCount) {
            cvh.mChannelUserCount.setVisibility(View.VISIBLE);
            int userCount = channel.getSubchannelUserCount();
            cvh.mChannelUserCount.setText(String.format("%d", userCount));
        } else {
            cvh.mChannelUserCount.setVisibility(View.GONE);
        }

        // Pad the view depending on channel's nested level.
        DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
        float margin = node.getDepth() * TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, metrics);
        cvh.mChannelHolder.setPadding((int) margin, cvh.mChannelHolder.getPaddingTop(),
                cvh.mChannelHolder.getPaddingRight(), cvh.mChannelHolder.getPaddingBottom());

        cvh.mJoinButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mService.joinChannel(channel.getId());
            }
        });

        cvh.mMoreButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ChannelMenu menu = new ChannelMenu(mContext, channel, mService, mDatabase, mFragmentManager);
                menu.showPopup(v);
            }
        });

        cvh.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                cvh.mMoreButton.performClick();
                return true;
            }
        });
    } else if (node.isUser()) {
        final IUser user = node.getUser();
        final UserViewHolder uvh = (UserViewHolder) viewHolder;
        uvh.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mUserClickListener != null) {
                    mUserClickListener.onUserClick(user);
                }
            }
        });

        uvh.mUserName.setText(user.getName());
        uvh.mUserName.setTypeface(null,
                user.getSession() == mService.getSession() ? Typeface.BOLD : Typeface.NORMAL);

        uvh.mUserTalkHighlight.setImageDrawable(getTalkStateDrawable(user));
        uvh.mTalkingIndicator.setAlpha(
                (user.getTalkState() == TalkState.TALKING || user.getTalkState() == TalkState.WHISPERING
                        || user.getTalkState() == TalkState.SHOUTING) ? 1 : 0);

        // Pad the view depending on channel's nested level.
        DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
        float margin = (node.getDepth() + 1)
                * TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, metrics);
        uvh.mUserHolder.setPadding((int) margin, uvh.mUserHolder.getPaddingTop(),
                uvh.mUserHolder.getPaddingRight(), uvh.mUserHolder.getPaddingBottom());

        uvh.mMoreButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UserMenu menu = new UserMenu(mContext, user, (PlumbleService) mService, mFragmentManager,
                        ChannelListAdapter.this);
                menu.showPopup(v);
            }
        });

        uvh.itemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                uvh.mMoreButton.performClick();
                return true;
            }
        });
    }
}

From source file:com.landenlabs.all_devtool.TextFragment.java

private void fillLayout() {
    m_tableLayout.removeAllViews();/* ww  w . j a v a 2s. co  m*/
    m_textInfoList.clear();

    int minSP = 8;
    int maxSP = 20;
    int stepSP = 2;

    int[] colors = new int[] { 0xffe0e0e0, 0xffffe0e0, 0xffe0ffe0, 0xffe0e0ff };

    TableLayout.LayoutParams tableLP = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
            TableLayout.LayoutParams.WRAP_CONTENT);
    TableRow.LayoutParams rowLP = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
            TableRow.LayoutParams.MATCH_PARENT);

    TextView textView;
    TableRow tableRow;
    int textColor = 0xff000000;

    for (int tfIdx = 0; tfIdx < TextInfo.getCount(); tfIdx++) {
        Typeface typeface = TextInfo.getTypeface(tfIdx);
        String typefaceStr = TextInfo.getTypefaceStr(tfIdx);

        textView = new TextView(m_context);
        textView.setBackgroundColor(Utils.blend(colors[tfIdx], 0x20000000));
        textView.setText(typefaceStr);
        textView.setGravity(Gravity.CENTER);
        textView.setTextColor(textColor);
        m_tableLayout.addView(textView, tableLP);

        for (int sizeSP = minSP; sizeSP <= maxSP; sizeSP += stepSP) {
            tableRow = new TableRow(m_context);
            tableRow.setBackgroundColor(colors[tfIdx]);

            tableRow.setTag(Integer.valueOf(m_textInfoList.size()));
            m_textInfoList.add(new TextInfo(sizeSP, tfIdx));

            tableRow.setClickable(true);
            tableRow.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    int idx = (Integer) v.getTag();
                    showTextDialog(m_textInfoList, idx);
                }
            });

            textView = new TextView(m_context);
            textView.setText(String.valueOf(sizeSP) + "sp ");
            textView.setBackgroundColor(0x20000000);
            textView.setPadding(8, 0, 8, 0);
            textView.setGravity(Gravity.CENTER);
            textView.setTextColor(textColor);
            tableRow.addView(textView, rowLP);

            textView = new TextView(m_context);
            textView.setText("Normal");
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSP);
            textView.setTypeface(typeface, Typeface.NORMAL);
            textView.setGravity(Gravity.CENTER);
            textView.setTextColor(textColor);
            tableRow.addView(textView, rowLP);

            textView = new TextView(m_context);
            textView.setText("Bold");
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSP);
            textView.setTypeface(typeface, Typeface.BOLD);
            textView.setPadding(8, 0, 8, 0);
            textView.setGravity(Gravity.CENTER);
            textView.setTextColor(textColor);
            tableRow.addView(textView, rowLP);

            textView = new TextView(m_context);
            textView.setText("Italic");
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSP);
            textView.setTypeface(typeface, Typeface.ITALIC);
            textView.setGravity(Gravity.CENTER);
            textView.setTextColor(textColor);
            tableRow.addView(textView, rowLP);

            m_tableLayout.addView(tableRow, tableLP);
        }
    }
}

From source file:org.cvasilak.jboss.mobile.app.fragments.RuntimeViewFragment.java

private void buildTable() {
    Map<String, List<String>> table = new HashMap<String, List<String>>();

    table.put("Server Status", Arrays.asList("Configuration", "JVM"));

    List<String> metrics = new ArrayList<String>(
            Arrays.asList("Data Sources", "JMS Destinations", "Transactions"));
    // 'Web' section metrics is compatible (for now) only with MANAGEMENT_VERSION_1
    // TODO ('Undertow' subsystem metrics can possible replace)
    if (application.getOperationsManager()
            .getVersion() == JBossOperationsManager.ManagementVersion.MANAGEMENT_VERSION_1) {
        metrics.add("Web");
    }//from  w  ww  .  ja  v  a  2s. com

    table.put("Subsystem Metrics", metrics);

    if (application.getOperationsManager().isDomainController()) {
        table.put("Deployments", Arrays.asList("Deployment Content", "Server Groups"));
    } else {
        table.put("Deployments", Arrays.asList("Manage Deployments"));
    }

    MergeAdapter adapter = new MergeAdapter();

    // cater for domain mode and display a button
    // for the user to change the active server
    if (application.getOperationsManager().isDomainController()) {
        chooseServer = new Button(getActivity());
        chooseServer.setText(application.getOperationsManager().getDomainHost() + ":"
                + application.getOperationsManager().getDomainServer());
        chooseServer.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_servers_selection, 0);
        chooseServer.setTypeface(null, Typeface.ITALIC);
        chooseServer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showDomainHostChooser();
            }
        });

        adapter.addView(chooseServer);
    }

    for (Map.Entry<String, List<String>> entry : table.entrySet()) {
        // add section header
        TextView section = new TextView(getActivity());
        section.setBackgroundColor(Color.DKGRAY);
        section.setPadding(15, 10, 0, 10);
        section.setText(entry.getKey());
        adapter.addView(section);

        // add section data
        adapter.addAdapter(
                new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, entry.getValue()));
    }

    setListAdapter(adapter);
}