Example usage for android.widget TextView setOnClickListener

List of usage examples for android.widget TextView setOnClickListener

Introduction

In this page you can find the example usage for android.widget TextView setOnClickListener.

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java

private View makeItem(final Pair<String, String> item, final int index) {
    TextView textView = createItemBase();
    textView.setText(item.second);/*from   w w  w . j a  v a  2 s .  c om*/

    if ("2".equals(item.first)) {
        textView.setTextColor(COLOR_ITEM_ALERT);
    } else if ("0".equals(item.first)) {
        textView.setTextColor(COLOR_ITEM_NORMAL);
    } else {
        return null;
    }
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(48)));
    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (actionListener != null) {
                actionListener.onSelected(index, item.second);
                dismiss();
            }
        }
    });

    return textView;
}

From source file:com.xander.panel.PanelController.java

private void applySheet() {
    mPanelRoot.removeAllViews();/*from  w w  w.j a  v  a 2s. c  o  m*/
    LayoutInflater inflater = LayoutInflater.from(mContext);
    View sheetView = inflater.inflate(R.layout.xander_panel_sheet, mRootLayout, false);
    TextView sheetCancel = (TextView) sheetView.findViewById(R.id.xander_panel_sheet_cancel);
    sheetCancel.setVisibility(mShowSheetCancel ? View.VISIBLE : View.GONE);
    sheetCancel.setText(mSheetCancelStr);
    sheetCancel.setOnClickListener(this);
    ListView sheetList = (ListView) sheetView.findViewById(R.id.xander_panel_sheet_list);
    SheetAdapter sheetAdapter = new SheetAdapter(mContext, this.mSheetItems);
    sheetList.setAdapter(sheetAdapter);
    sheetList.setOnItemClickListener(panelItemClickListenr);
    //        sheetList.setOnItemLongClickListener(panelItemClickListenr);
    mPanelRoot.addView(sheetView);
}

From source file:com.hx.hxchat.activity.ChatHistoryFragment.java

/**
 * /*from   w  ww.  ja v  a  2  s .c o m*/
 * @param title 
 * @param emContact
 */
private void showMyDialog(String title, final ChatHistoryAdapter adapter, final int position) {

    final AlertDialog dlg = new AlertDialog.Builder(context).create();
    dlg.show();
    Window window = dlg.getWindow();
    // ??,shrew_exit_dialog.xmlview
    window.setContentView(R.layout.alertdialog);

    window.findViewById(R.id.ll_title).setVisibility(View.VISIBLE);

    TextView tv_title = (TextView) window.findViewById(R.id.tv_title);
    tv_title.setText(title);

    TextView tv_content1 = (TextView) window.findViewById(R.id.tv_content1);
    final String username = adapter.getItem(position).getUsername();
    // ??

    if (topMap.containsKey(username)) {
        tv_content1.setText("?");

    } else {
        tv_content1.setText("?");

    }

    tv_content1.setOnClickListener(new View.OnClickListener() {
        @SuppressLint("SdCardPath")
        public void onClick(View v) {

            if (topMap.containsKey(username)) {

                topMap.remove(username);
                TopUserDao topUserDao = new TopUserDao(context);

                topUserDao.deleteTopUser(username);

            } else {
                TopUser topUser = new TopUser();
                topUser.setTime(System.currentTimeMillis());
                // 1---
                topUser.setType(1);
                topUser.setUserName(username);
                Map<String, TopUser> map = new HashMap<String, TopUser>();
                map.put(adapter.getItem(position).getUsername(), topUser);
                topMap.putAll(map);
                TopUserDao topUserDao = new TopUserDao(context);
                topUserDao.saveTopUser(topUser);

            }
            refresh();
            dlg.cancel();
        }
    });
    TextView tv_content2 = (TextView) window.findViewById(R.id.tv_content2);
    tv_content2.setText("?");
    tv_content2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            EMContact tobeDeleteUser = adapter.getItem(position);
            EMChatManager.getInstance().deleteConversation(adapter.getItem(position).getUsername());
            InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(context);
            inviteMessgeDao.deleteMessage(tobeDeleteUser.getUsername());

            BaseApplication.getApplication().GetLinkerDao().deleteContact(tobeDeleteUser.getUsername());
            adapter.remove(tobeDeleteUser);
            adapter.notifyDataSetChanged();
            //              ((MainActivity) context).homefragment.refresh();

            //           boolean isGroup = false;
            //           
            //           
            //           if (tobeDeleteUser instanceof EMGroup)
            //              isGroup = true;
            //
            //           // ?
            //           boolean deleteConversation = EMChatManager.getInstance().deleteConversation(tobeDeleteUser.getUsername());
            //           InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity());
            //           inviteMessgeDao.deleteMessage(tobeDeleteUser.getUsername());
            //
            //           BaseApplication.getApplication().GetLinkerDao().deleteContact(tobeDeleteUser.getUsername());
            //           adapter.remove(tobeDeleteUser);
            //           adapter.notifyDataSetChanged();
            //
            //           // ?
            //           // TODO
            //           // ((MainActivity) getActivity()).updateUnreadLabel();
            //
            //              
            //              

            dlg.cancel();

        }
    });

}

From source file:net.oschina.app.v2.activity.zxing.CaptureActivity.java

private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
    //- ------------------------------------------------------- //
    String text = rawResult.getText();
    if (text != null && StringUtils.isUrl(text)) {
        if (text.contains("scan_login")) {
            statusView.setVisibility(View.GONE);
            viewfinderView.setVisibility(View.GONE);
            showConfirmLogin(text);/*  w  w  w . j  a v a  2  s.co m*/
            return;
        }
        if (text.contains("oschina.net")) {
            UIHelper.showUrlRedirect(CaptureActivity.this, text);
            finish();
            return;
        }
    }
    try {
        BarCode2 bc = BarCode2.parse(text);
        int type = bc.getType();
        switch (type) {
        case BarCode2.SIGN_IN:// 
            handleSignIn(bc);
            return;
        default:
            break;
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    //- ------------------------------------------------------- //
    CharSequence displayContents = resultHandler.getDisplayContents();

    if (copyToClipboard && !resultHandler.areContentsSecure()) {
        ClipboardInterface.setText(displayContents, this);
    }

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    if (resultHandler.getDefaultButtonID() != null
            && prefs.getBoolean(PreferencesActivity.KEY_AUTO_OPEN_WEB, false)) {
        resultHandler.handleButtonPress(resultHandler.getDefaultButtonID());
        return;
    }

    statusView.setVisibility(View.GONE);
    viewfinderView.setVisibility(View.GONE);
    resultView.setVisibility(View.VISIBLE);

    ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view);
    if (barcode == null) {
        barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.app_icon));
    } else {
        barcodeImageView.setImageBitmap(barcode);
    }

    TextView formatTextView = (TextView) findViewById(R.id.format_text_view);
    formatTextView.setText(rawResult.getBarcodeFormat().toString());

    TextView typeTextView = (TextView) findViewById(R.id.type_text_view);
    typeTextView.setText(resultHandler.getType().toString());

    DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    TextView timeTextView = (TextView) findViewById(R.id.time_text_view);
    timeTextView.setText(formatter.format(new Date(rawResult.getTimestamp())));

    TextView metaTextView = (TextView) findViewById(R.id.meta_text_view);
    View metaTextViewLabel = findViewById(R.id.meta_text_view_label);
    metaTextView.setVisibility(View.GONE);
    metaTextViewLabel.setVisibility(View.GONE);
    Map<ResultMetadataType, Object> metadata = rawResult.getResultMetadata();
    if (metadata != null) {
        StringBuilder metadataText = new StringBuilder(20);
        for (Map.Entry<ResultMetadataType, Object> entry : metadata.entrySet()) {
            if (DISPLAYABLE_METADATA_TYPES.contains(entry.getKey())) {
                metadataText.append(entry.getValue()).append('\n');
            }
        }
        if (metadataText.length() > 0) {
            metadataText.setLength(metadataText.length() - 1);
            metaTextView.setText(metadataText);
            metaTextView.setVisibility(View.VISIBLE);
            metaTextViewLabel.setVisibility(View.VISIBLE);
        }
    }

    TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view);
    contentsTextView.setText(displayContents);
    int scaledSize = Math.max(22, 32 - displayContents.length() / 4);
    contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize);

    TextView supplementTextView = (TextView) findViewById(R.id.contents_supplement_text_view);
    supplementTextView.setText("");
    supplementTextView.setOnClickListener(null);
    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(PreferencesActivity.KEY_SUPPLEMENTAL,
            true)) {
        //SupplementalInfoRetriever.maybeInvokeRetrieval(supplementTextView,
        //        resultHandler.getResult(),
        //        historyManager,
        //        this);
    }

    int buttonCount = resultHandler.getButtonCount();
    ViewGroup buttonView = (ViewGroup) findViewById(R.id.result_button_view);
    buttonView.requestFocus();
    for (int x = 0; x < ResultHandler.MAX_BUTTON_COUNT; x++) {
        TextView button = (TextView) buttonView.getChildAt(x);
        if (x < buttonCount) {
            button.setVisibility(View.VISIBLE);
            button.setText(resultHandler.getButtonText(x));
            button.setOnClickListener(new ResultButtonListener(resultHandler, x));
        } else {
            button.setVisibility(View.GONE);
        }
    }
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionDetailFragment.java

/**
 * Handle {@link SessionsQuery} {@link Cursor}.
 *//* w w  w  . ja v  a  2  s  .co m*/
private void onSessionQueryComplete(Cursor cursor) {
    mSessionCursor = true;
    if (!cursor.moveToFirst()) {
        if (isAdded()) {
            // TODO: Remove this in favor of a callbacks interface that the activity
            // can implement.
            getActivity().finish();
        }
        return;
    }

    mTitleString = cursor.getString(SessionsQuery.TITLE);

    // Format time block this session occupies
    mSessionBlockStart = cursor.getLong(SessionsQuery.BLOCK_START);
    mSessionBlockEnd = cursor.getLong(SessionsQuery.BLOCK_END);
    String roomName = cursor.getString(SessionsQuery.ROOM_NAME);
    final String subtitle = UIUtils.formatSessionSubtitle(mTitleString, mSessionBlockStart, mSessionBlockEnd,
            roomName, mBuffer, getActivity());

    mTitle.setText(mTitleString);

    mUrl = cursor.getString(SessionsQuery.URL);
    if (TextUtils.isEmpty(mUrl)) {
        mUrl = "";
    }

    mHashtags = cursor.getString(SessionsQuery.HASHTAGS);
    if (!TextUtils.isEmpty(mHashtags)) {
        enableSocialStreamMenuItemDeferred();
    }

    mRoomId = cursor.getString(SessionsQuery.ROOM_ID);

    setupShareMenuItemDeferred();
    showStarredDeferred(mInitStarred = (cursor.getInt(SessionsQuery.STARRED) != 0), false);

    final String sessionAbstract = cursor.getString(SessionsQuery.ABSTRACT);
    if (!TextUtils.isEmpty(sessionAbstract)) {
        UIUtils.setTextMaybeHtml(mAbstract, sessionAbstract);
        mAbstract.setVisibility(View.VISIBLE);
        mHasSummaryContent = true;
    } else {
        mAbstract.setVisibility(View.GONE);
    }

    updatePlusOneButton();

    final View requirementsBlock = mRootView.findViewById(R.id.session_requirements_block);
    final String sessionRequirements = cursor.getString(SessionsQuery.REQUIREMENTS);
    if (!TextUtils.isEmpty(sessionRequirements)) {
        UIUtils.setTextMaybeHtml(mRequirements, sessionRequirements);
        requirementsBlock.setVisibility(View.VISIBLE);
        mHasSummaryContent = true;
    } else {
        requirementsBlock.setVisibility(View.GONE);
    }

    // Show empty message when all data is loaded, and nothing to show
    if (mSpeakersCursor && !mHasSummaryContent) {
        mRootView.findViewById(android.R.id.empty).setVisibility(View.VISIBLE);
    }

    // Compile list of links (I/O live link, submit feedback, and normal links)
    ViewGroup linkContainer = (ViewGroup) mRootView.findViewById(R.id.links_container);
    linkContainer.removeAllViews();

    final Context context = mRootView.getContext();

    List<Pair<Integer, Intent>> links = new ArrayList<Pair<Integer, Intent>>();

    final boolean hasLivestream = !TextUtils.isEmpty(cursor.getString(SessionsQuery.LIVESTREAM_URL));
    long currentTimeMillis = UIUtils.getCurrentTime(context);
    if (UIUtils.hasHoneycomb() // Needs Honeycomb+ for the live stream
            && hasLivestream && currentTimeMillis > mSessionBlockStart
            && currentTimeMillis <= mSessionBlockEnd) {
        links.add(new Pair<Integer, Intent>(R.string.session_link_livestream,
                new Intent(Intent.ACTION_VIEW, mSessionUri).setClass(context,
                        SessionLivestreamActivity.class)));
    }

    // Add session feedback link
    //   links.add(new Pair<Integer, Intent>(
    //          R.string.session_feedback_submitlink,
    //           new Intent(Intent.ACTION_VIEW, mSessionUri, getActivity(), SessionFeedbackActivity.class)
    //   ));

    for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) {
        final String linkUrl = cursor.getString(SessionsQuery.LINKS_INDICES[i]);
        if (TextUtils.isEmpty(linkUrl)) {
            continue;
        }

        links.add(new Pair<Integer, Intent>(SessionsQuery.LINKS_TITLES[i],
                new Intent(Intent.ACTION_VIEW, Uri.parse(linkUrl))
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)));
    }

    // Render links
    if (links.size() > 0) {
        LayoutInflater inflater = LayoutInflater.from(context);
        int columns = context.getResources().getInteger(R.integer.links_columns);

        LinearLayout currentLinkRowView = null;
        for (int i = 0; i < links.size(); i++) {
            final Pair<Integer, Intent> link = links.get(i);

            // Create link view
            TextView linkView = (TextView) inflater.inflate(R.layout.list_item_session_link, linkContainer,
                    false);
            linkView.setText(getString(link.first));
            linkView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    fireLinkEvent(link.first);
                    try {
                        startActivity(link.second);
                    } catch (ActivityNotFoundException ignored) {
                    }
                }
            });

            // Place it inside a container
            if (columns == 1) {
                linkContainer.addView(linkView);
            } else {
                // create a new link row
                if (i % columns == 0) {
                    currentLinkRowView = (LinearLayout) inflater.inflate(R.layout.include_link_row,
                            linkContainer, false);
                    currentLinkRowView.setWeightSum(columns);
                    linkContainer.addView(currentLinkRowView);
                }

                ((LinearLayout.LayoutParams) linkView.getLayoutParams()).width = 0;
                ((LinearLayout.LayoutParams) linkView.getLayoutParams()).weight = 1;
                currentLinkRowView.addView(linkView);
            }
        }

        mRootView.findViewById(R.id.session_links_header).setVisibility(View.VISIBLE);
        mRootView.findViewById(R.id.links_container).setVisibility(View.VISIBLE);

    } else {
        mRootView.findViewById(R.id.session_links_header).setVisibility(View.GONE);
        mRootView.findViewById(R.id.links_container).setVisibility(View.GONE);
    }

    // Show past/present/future and livestream status for this block.
    UIUtils.updateTimeAndLivestreamBlockUI(context, mSessionBlockStart, mSessionBlockEnd, hasLivestream, null,
            mSubtitle, subtitle);

    EasyTracker.getTracker().sendView("Session: " + mTitleString);
    LOGD("Tracker", "Session: " + mTitleString);
}

From source file:com.heath_bar.tvdb.SeriesOverview.java

/** Populate the interface with the data pulled from the webz */
private void PopulateStuff(TvSeries seriesInfo) {

    if (seriesInfo == null) {
        Toast.makeText(getApplicationContext(), "Something bad happened. No data was found.",
                Toast.LENGTH_SHORT).show();
        return;//from   www .  j av a2s .co  m
    }

    // Set title
    getSupportActionBar().setTitle(seriesInfo.getName());

    // Hide/Activate the favorites button
    if (seriesInfo.isFavorite(getApplicationContext())) {
        Button b = (Button) findViewById(R.id.btn_add_to_favorites);
        b.setVisibility(View.GONE);
    } else {
        Button b = (Button) findViewById(R.id.btn_add_to_favorites);
        b.setVisibility(View.VISIBLE);
        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Button b = (Button) findViewById(R.id.btn_add_to_favorites);
                b.setVisibility(View.GONE);
                addToFavorites();
            }
        });
    }

    // Set the banner
    ImageView imageView = (ImageView) findViewById(R.id.series_banner);
    imageView.setImageBitmap(seriesInfo.getImage().getBitmap());
    imageView.setVisibility(View.VISIBLE);
    final String seriesName = seriesInfo.getName();

    imageView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            shareImage();
        }
    });

    // Set the banner link
    TextView textview = (TextView) findViewById(R.id.banner_listing_link);
    textview.setTextColor(getResources().getColor(R.color.tvdb_green));
    textview.setVisibility(View.VISIBLE);
    textview.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(getApplicationContext(), BannerListing.class);
            i.putExtra("seriesId", seriesId);
            i.putExtra("seriesName", seriesName);
            startActivity(i);
        }
    });

    // Set air info
    textview = (TextView) findViewById(R.id.airs_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.last_episode);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.next_episode);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.series_air_info);
    StringBuffer sb = new StringBuffer();
    sb.append(seriesInfo.getAirDay());
    if (!seriesInfo.getAirTime().equals(""))
        sb.append(" at " + seriesInfo.getAirTime());
    if (!seriesInfo.getNetwork().equals(""))
        sb.append(" on " + seriesInfo.getNetwork());
    textview.setText(sb.toString());
    textview.setVisibility(View.VISIBLE);

    // Set actors
    textview = (TextView) findViewById(R.id.starring);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.series_actors);
    textview.setVisibility(View.VISIBLE);

    SpannableStringBuilder text = tagsBuilder(seriesInfo.getActors(), "|");
    textview.setText(text, BufferType.SPANNABLE);
    textview.setMovementMethod(LinkMovementMethod.getInstance());

    // Set rating
    textview = (TextView) findViewById(R.id.rating_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.rating);
    textview.setText(seriesInfo.getRating() + " / 10");
    textview.setVisibility(View.VISIBLE);

    // Set genre
    textview = (TextView) findViewById(R.id.genre_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.genre);
    textview.setText(StringUtil.commafy(seriesInfo.getGenre()));
    textview.setVisibility(View.VISIBLE);

    // Set runtime
    textview = (TextView) findViewById(R.id.runtime_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.runtime);
    textview.setText(seriesInfo.getRuntime() + " minutes");
    textview.setVisibility(View.VISIBLE);

    // Set overview
    textview = (TextView) findViewById(R.id.overview_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.overview);
    textview.setText(seriesInfo.getOverview());
    textview.setVisibility(View.VISIBLE);

    // Show Seasons header
    textview = (TextView) findViewById(R.id.seasons_header);
    textview.setVisibility(View.VISIBLE);

    // IMDB Link
    textview = (TextView) findViewById(R.id.imdb_link);
    textview.setVisibility(View.VISIBLE);

    final String imdbId = seriesInfo.getIMDB();
    SpannableStringBuilder ssb = new SpannableStringBuilder(getResources().getString(R.string.imdb));
    ssb.setSpan(new NonUnderlinedClickableSpan(getResources().getString(R.string.imdb)) {
        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.imdb.com/title/" + imdbId));
            startActivity(myIntent);
        }
    }, 0, ssb.length(), 0);

    ssb.setSpan(new TextAppearanceSpan(this, R.style.episode_link), 0, ssb.length(), 0); // Set the style of the text
    textview.setText(ssb, BufferType.SPANNABLE);
    textview.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:com.ltf.mytoolslibrary.viewbase.viewPagerGuidanceActivityMyLib.SpringIndicator.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void addTabItems() {
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(20, 20);
    tabs = new ArrayList<>();
    layoutParams.setMargins(15, 0, 15, 0);
    for (int i = 0; i < viewPager.getAdapter().getCount(); i++) {
        TextView textView = new TextView(getContext());
        if (viewPager.getAdapter().getPageTitle(i) != null) {
            textView.setText(viewPager.getAdapter().getPageTitle(i));
        }/*from   w  w  w  .java 2  s  .  co  m*/
        textView.setGravity(Gravity.CENTER);
        //            textView.setBackground(getResources().getDrawable(R.drawable.steward_msg_red));
        textView.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.circle_orange));
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        textView.setTextColor(getResources().getColor(textColorId));
        if (textBgResId != 0) {
            textView.setBackgroundResource(textBgResId);
        }
        textView.setLayoutParams(layoutParams);
        final int position = i;
        textView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (tabClickListener == null || tabClickListener.onTabClick(position)) {
                    viewPager.setCurrentItem(position);
                }
            }
        });
        tabs.add(textView);
        tabContainer.addView(textView);
    }
}

From source file:com.swiftkaydevelopment.fullsailcommunicate.activities.HomeActivity.java

private View setUpHeader(View header) {
    TextView tvName = (TextView) header.findViewById(R.id.tvDrawerHeaderName);
    ImageView ivusersphoto = (ImageView) header.findViewById(R.id.ivDrawerHeaderProfilePicture);

    tvName.setText(prefs.getString(AppConstants.PREFERENCE_NAMES.PREF_FIRSTNAME, MockData.FIRSTNAME) + " "
            + prefs.getString(AppConstants.PREFERENCE_NAMES.PREF_LASTNAME, MockData.LASTNAME));
    String imgLoc = prefs.getString(AppConstants.PREFERENCE_NAMES.PREF_PRO_PIC_LOC,
            MockData.PROFILE_PICTURE_LOCATION);
    if (!TextUtils.isEmpty(imgLoc)) {
        Picasso.with(this).load(imgLoc).transform(new CircleTransform()).into(ivusersphoto);
    } else {//from ww  w .j  av a 2  s  .  co m
        Picasso.with(this).load(R.drawable.profile_pic_blank_150).transform(new CircleTransform())
                .into(ivusersphoto);
    }

    tvName.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mDrawerLayout != null) {
                mDrawerLayout.closeDrawers();
            }

            ProfileFragment fragment = (ProfileFragment) getSupportFragmentManager()
                    .findFragmentByTag(ProfileFragment.TAG);
            if (fragment == null) {
                fragment = ProfileFragment.newInstance(uid);
            }
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.frame_container, fragment, ProfileFragment.TAG).addToBackStack(null).commit();
        }
    });

    ivusersphoto.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mDrawerLayout != null) {
                mDrawerLayout.closeDrawers();
            }

            ProfileFragment fragment = (ProfileFragment) getSupportFragmentManager()
                    .findFragmentByTag(ProfileFragment.TAG);
            if (fragment == null) {
                fragment = ProfileFragment.newInstance(uid);
            }
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.frame_container, fragment, ProfileFragment.TAG).addToBackStack(null).commit();
        }
    });
    return header;
}

From source file:com.hybris.mobile.app.commerce.fragment.CatalogMenuFragment.java

/**
 * Add a child view to the view flipper//from   w w  w. j  a v a2  s.  c  o m
 *
 * @param parent
 * @param showCatalogMenuLogo
 */
private void buildChildrenView(final CategoryHierarchy parent, boolean showCatalogMenuLogo, boolean showNext) {
    // Layout for the view
    final View view = getActivity().getLayoutInflater().inflate(R.layout.include_catalog_menu_categories,
            mCatalogMenuViewFlipper, false);

    TextView textViewTopCategoryName = (TextView) view.findViewById(R.id.catalog_menu_top_category_name);
    RelativeLayout relativeLayoutTopCategory = (RelativeLayout) view
            .findViewById(R.id.catalog_menu_top_category);
    ListView listViewCategories = (ListView) view.findViewById(R.id.catalog_menu_list_category);

    // We set to visible the top category name
    relativeLayoutTopCategory.setVisibility(View.VISIBLE);

    // Setting the top category name
    textViewTopCategoryName.setText(parent.getName());
    textViewTopCategoryName.setVisibility(View.VISIBLE);
    textViewTopCategoryName.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (parent.getParent() != null) {
                mCurrentCategoryId = parent.getParent().getId();
            } else {
                mCurrentCategoryId = null;
            }

            // On click of the top category, we go back to the top view
            mCatalogMenuViewFlipper.setInAnimation(getActivity(), R.anim.translate_left_to_origin);
            mCatalogMenuViewFlipper.setOutAnimation(getActivity(), R.anim.translate_origin_to_right);
            mCatalogMenuViewFlipper.showPrevious();

            // And we remove the view we just came by
            mCatalogMenuViewFlipper.removeViewAt(mCatalogMenuViewFlipper.getChildCount() - 1);

            // We display the catalog logo if we are on the top view
            if (mCatalogMenuViewFlipper.getChildCount() == 1) {
                showCatalogMenuLogo(view, true);
            }

            // Updating the content view
            updateContentView(parent.getParent(), false);

        }
    });

    // Setting the list for the sub categories
    initListViewCatalog(listViewCategories, parent.getSubcategories());

    // Show the subcategories
    mCatalogMenuViewFlipper.addView(view);

    if (showNext) {
        mCatalogMenuViewFlipper.setInAnimation(getActivity(), R.anim.translate_right_to_origin);
        mCatalogMenuViewFlipper.setOutAnimation(getActivity(), R.anim.translate_origin_to_left);
        mCatalogMenuViewFlipper.showNext();

        // Updating the content view once the ViewFlipper has finished his animation
        updateContentView(parent, false);
    }

    // Hidding the catalog logo on subcategories
    showCatalogMenuLogo(view, showCatalogMenuLogo);

}

From source file:me.piebridge.prevent.ui.UserGuideActivity.java

private boolean setView(int id, String packageName) {
    TextView donate = (TextView) findViewById(id);
    PackageManager pm = getPackageManager();
    try {/*from   w w w  . j av  a  2  s  .c  o  m*/
        ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
        if (!info.enabled) {
            return false;
        }
        CharSequence label = getLabel(pm, info);
        donate.setContentDescription(label);
        donate.setCompoundDrawablesWithIntrinsicBounds(null, cropDrawable(pm.getApplicationIcon(info)), null,
                null);
        donate.setText(label);
        donate.setClickable(true);
        donate.setOnClickListener(this);
        donate.setVisibility(View.VISIBLE);
        return true;
    } catch (PackageManager.NameNotFoundException e) {
        UILog.d("cannot find package " + packageName, e);
        return false;
    }
}