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.coact.kochzap.CaptureActivity.java

private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {

    maybeSetClipboard(resultHandler);/*from w  ww  .jav  a  2  s.  c o  m*/

    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.launcher_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(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);
        }
    }

    CharSequence displayContents = resultHandler.getDisplayContents();
    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.maxleapmobile.gitmaster.ui.fragment.RecommendFragment.java

private void initUI(View view) {
    actionArea = (LinearLayout) view.findViewById(R.id.recommend_action_area);
    starProgressBar = (ProgressBar) view.findViewById(R.id.recommend_star_progressbar);
    starText = (TextView) view.findViewById(R.id.recommend_star);
    starText.setOnClickListener(this);
    view.findViewById(R.id.recommend_fork).setOnClickListener(this);
    skipBtn = view.findViewById(R.id.recommend_skip);
    skipBtn.setOnClickListener(this);
    mProgressBar = (ProgressBar) view.findViewById(R.id.repo_progressbar);
    TextView notice2 = (TextView) view.findViewById(R.id.recommend_notice2);
    SpannableString notice2SS = new SpannableString(mContext.getString(R.string.recommend_notice2_part1) + " "
            + mContext.getString(R.string.recommend_notice2_part2));
    notice2SS.setSpan(new CustomClickableSpan(), 0,
            mContext.getString(R.string.recommend_notice2_part1).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    notice2.setText(notice2SS);//from   w w  w  . j  av a2 s  .c o  m
    notice2.setOnClickListener(this);
    notice3 = (TextView) view.findViewById(R.id.recommend_notice3);
    final SpannableString notice3SS = new SpannableString(mContext.getString(R.string.recommend_notice3_part1)
            + " " + mContext.getString(R.string.recommend_notice3_part2));
    notice3SS.setSpan(new CustomClickableSpan(), mContext.getString(R.string.recommend_notice3_part1).length(),
            notice3SS.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    notice3.setText(notice3SS);
    notice3.setOnClickListener(this);

    mWebView = (ProgressWebView) view.findViewById(R.id.recommend_webview);
    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            mProgressBar.setVisibility(View.GONE);
        }
    });

    mEmptyView = (LinearLayout) view.findViewById(R.id.recommend_empty);
    mEmptyView.setVisibility(View.GONE);
    if (mParmasMap == null) {
        mParmasMap = new HashMap();
        mParmasMap.put("userid", username);
        mParmasMap.put("page", page);
        mParmasMap.put("per_page", PER_PAGE);
    }
}

From source file:com.keepsafe.switchboard.example.SwitchBoardExampleAppActivity.java

@Override
protected void onResume() {
    super.onResume();
    //see if we're in experiment "homeScreenMessage" that we defined on the server
    if (SwitchBoard.isInExperiment(this, "homeScreenMessage")) {
        Log.d(TAG, "isInExperiment homeScreen");
        //check if the experiment has values. Only needed when passing custom variables
        if (SwitchBoard.hasExperimentValues(this, "homeScreenMessage")) {
            Log.d(TAG, "has values");
            TextView tv = (TextView) findViewById(R.id.messagebox);
            tv.setVisibility(View.VISIBLE);

            //get experiment values
            JSONObject values = SwitchBoard.getExperimentValueFromJson(this, "homeScreenMessage");
            try {
                //getting the user specific values
                String message = values.getString("message");
                String messageTitle = values.getString("messageTitle");

                tv.setText(Html.fromHtml(message));
                Log.d(TAG, "set message text in UI");

                /* Track the view in your preferred analytics
                 * using messageTitle to track test 
                 *//*from  www  . ja va2s . com*/

                //tracks when user clicks on HTML link from your A/B test
                tv.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        /* Track the click in your preferred analytics
                         * using messageTitle to track test 
                         */
                    }
                });

            } catch (JSONException e) {
                //catches if your requested JSON object is not in values
                e.printStackTrace();
            }
        }
    }
}

From source file:com.example.rosem.TravelPlanner.Fragment.SettingFragment.java

@Nullable
@Override/*from  w w w .j a  v  a 2 s  . c om*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.setting_layout, container, false);

    logout = (TextView) view.findViewById(R.id.logout);
    TextView license = (TextView) view.findViewById(R.id.license);

    logout.setTypeface(fontType);
    license.setTypeface(fontType);

    logout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            FirebaseAuth auth = FirebaseAuth.getInstance();
            FirebaseUser user = auth.getCurrentUser();
            if (user != null) {
                auth.signOut();
                Toast.makeText(getContext(), getString(R.string.logout_success), Toast.LENGTH_SHORT).show();
                logout.setText(getString(R.string.login));
            } else {
                Intent intent = new Intent(getContext(), SignInActivity.class);
                startActivityForResult(intent, SIGN_IN);

            }

        }
    });
    license.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.license_url)));
            startActivity(intent);
        }
    });

    return view;
}

From source file:brama.com.hearthum.waveform.WaveformFragment.java

protected void loadGui(View view) {
    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    mDensity = metrics.density;/*  w  w  w .j av a  2s. co  m*/

    mMarkerLeftInset = (int) (46 * mDensity);
    mMarkerRightInset = (int) (48 * mDensity);
    mMarkerTopOffset = (int) (10 * mDensity);
    mMarkerBottomOffset = (int) (10 * mDensity);

    mStartText = (TextView) view.findViewById(R.id.starttext);
    mStartText.addTextChangedListener(mTextWatcher);
    mEndText = (TextView) view.findViewById(R.id.endtext);
    mEndText.addTextChangedListener(mTextWatcher);

    mPlayButton = (ImageButton) view.findViewById(R.id.play);
    mPlayButton.setOnClickListener(mPlayListener);
    mRewindButton = (ImageButton) view.findViewById(R.id.rew);
    mRewindButton.setOnClickListener(getRewindListener());
    mFfwdButton = (ImageButton) view.findViewById(R.id.ffwd);
    mFfwdButton.setOnClickListener(getFwdListener());

    TextView markStartButton = (TextView) view.findViewById(R.id.mark_start);
    markStartButton.setOnClickListener(mMarkStartListener);
    TextView markEndButton = (TextView) view.findViewById(R.id.mark_end);
    markEndButton.setOnClickListener(mMarkEndListener);

    enableDisableButtons();

    mWaveformView = (WaveformView) view.findViewById(R.id.waveform);
    mWaveformView.setListener(this);

    mInfo = (TextView) view.findViewById(R.id.info);
    mInfo.setText(mCaption);

    mMaxPos = 0;
    mLastDisplayedStartPos = -1;
    mLastDisplayedEndPos = -1;

    if (mSoundFile != null && !mWaveformView.hasSoundFile()) {
        mWaveformView.setSoundFile(mSoundFile);
        mWaveformView.recomputeHeights(mDensity);
        mMaxPos = mWaveformView.maxPos();
    }

    mStartMarker = (MarkerView) view.findViewById(R.id.startmarker);
    mStartMarker.setListener(this);
    mStartMarker.setImageAlpha(255);
    mStartMarker.setFocusable(true);
    mStartMarker.setFocusableInTouchMode(true);
    mStartVisible = true;

    mEndMarker = (MarkerView) view.findViewById(R.id.endmarker);
    mEndMarker.setListener(this);
    mEndMarker.setImageAlpha(255);
    mEndMarker.setFocusable(true);
    mEndMarker.setFocusableInTouchMode(true);
    mEndVisible = true;

    updateDisplay();
}

From source file:com.hitesh_sahu.retailapp.view.fragment.ProductDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.frag_product_detail, container, false);
    scrollView = (ScrollView) rootView;/*from   w ww  .  j  a v  a2 s .com*/
    mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar);
    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar);
    }

    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        mToolbar.setNavigationIcon(R.drawable.ic_drawer);

    }

    mToolbar.setTitleTextColor(Color.WHITE);

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START);
        }
    });

    ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    similarProductsPager = (ClickableViewPager) rootView.findViewById(R.id.similar_products_pager);

    topSellingPager = (ClickableViewPager) rootView.findViewById(R.id.top_selleing_pager);

    itemSellPrice = ((TextView) rootView.findViewById(R.id.category_discount));

    quanitity = ((TextView) rootView.findViewById(R.id.iteam_amount));

    itemName = ((TextView) rootView.findViewById(R.id.product_name));

    itemdescription = ((TextView) rootView.findViewById(R.id.product_description));

    itemImage = (ImageView) rootView.findViewById(R.id.product_image);

    fillProductData();
    TextView addItem = (TextView) rootView.findViewById(R.id.add_item);
    FocusPin.with(getContext()).into(addItem).scrollView(scrollView).create();

    addItem.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            FocusPin.with(getContext()).destroy();
            /*if (null != mFrameLayout && mFrameLayout.isActivated()) {
                mWindowManager.removeViewImmediate(mFrameLayout);
                mFrameLayout.setActivated(false);
                ViewTreeObserver observer = scrollView.getViewTreeObserver();
                observer.removeOnScrollChangedListener(onScrollChangedListener);
            }*/
            if (isFromCart) {

                //Update Quantity on shopping List
                CenterRepository.getCenterRepository().getListOfProductsInShoppingList().get(productListNumber)
                        .setQuantity(String.valueOf(

                                Integer.valueOf(CenterRepository.getCenterRepository()
                                        .getListOfProductsInShoppingList().get(productListNumber).getQuantity())
                                        + 1));

                //Update Ui
                quanitity.setText(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                        .get(productListNumber).getQuantity());

                Utils.vibrate(getActivity());

                //Update checkout amount on screen
                ((ECartHomeActivity) getActivity()).updateCheckOutAmount(
                        BigDecimal.valueOf(Long.valueOf(CenterRepository.getCenterRepository()
                                .getListOfProductsInShoppingList().get(productListNumber).getSellMRP())),
                        true);

            } else {

                // current object
                Product tempObj = CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                        .get(subcategoryKey).get(productListNumber);

                // if current object is lready in shopping list
                if (CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                        .contains(tempObj)) {

                    // get position of current item in shopping list
                    int indexOfTempInShopingList = CenterRepository.getCenterRepository()
                            .getListOfProductsInShoppingList().indexOf(tempObj);

                    // increase quantity of current item in shopping
                    // list
                    if (Integer.parseInt(tempObj.getQuantity()) == 0) {

                        ((ECartHomeActivity) getContext()).updateItemCount(true);

                    }

                    // update quanity in shopping list
                    CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                            .get(indexOfTempInShopingList)
                            .setQuantity(String.valueOf(Integer.valueOf(tempObj.getQuantity()) + 1));

                    // update checkout amount
                    ((ECartHomeActivity) getContext())
                            .updateCheckOutAmount(
                                    BigDecimal.valueOf(Long.valueOf(
                                            CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                                                    .get(subcategoryKey).get(productListNumber).getSellMRP())),
                                    true);

                    // update current item quanitity
                    quanitity.setText(tempObj.getQuantity());

                } else {

                    ((ECartHomeActivity) getContext()).updateItemCount(true);

                    tempObj.setQuantity(String.valueOf(1));

                    quanitity.setText(tempObj.getQuantity());

                    CenterRepository.getCenterRepository().getListOfProductsInShoppingList().add(tempObj);
                    ((ECartHomeActivity) getContext()).getCheckOutView();
                    ((ECartHomeActivity) getContext())
                            .updateCheckOutAmount(
                                    BigDecimal.valueOf(Long.valueOf(
                                            CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                                                    .get(subcategoryKey).get(productListNumber).getSellMRP())),
                                    true);

                }

                Utils.vibrate(getContext());

            }
        }

    });

    rootView.findViewById(R.id.remove_item).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (isFromCart)

            {

                if (Integer.valueOf(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                        .get(productListNumber).getQuantity()) > 2) {

                    CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                            .get(productListNumber).setQuantity(String.valueOf(

                                    Integer.valueOf(CenterRepository.getCenterRepository()
                                            .getListOfProductsInShoppingList().get(productListNumber)
                                            .getQuantity()) - 1));

                    quanitity.setText(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                            .get(productListNumber).getQuantity());

                    ((ECartHomeActivity) getActivity()).updateCheckOutAmount(
                            BigDecimal.valueOf(Long.valueOf(CenterRepository.getCenterRepository()
                                    .getListOfProductsInShoppingList().get(productListNumber).getSellMRP())),
                            false);

                    Utils.vibrate(getActivity());
                } else if (Integer.valueOf(CenterRepository.getCenterRepository()
                        .getListOfProductsInShoppingList().get(productListNumber).getQuantity()) == 1) {
                    ((ECartHomeActivity) getActivity()).updateItemCount(false);

                    ((ECartHomeActivity) getActivity()).updateCheckOutAmount(
                            BigDecimal.valueOf(Long.valueOf(CenterRepository.getCenterRepository()
                                    .getListOfProductsInShoppingList().get(productListNumber).getSellMRP())),
                            false);

                    CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                            .remove(productListNumber);

                    if (Integer.valueOf(((ECartHomeActivity) getActivity()).getItemCount()) == 0) {

                        MyCartFragment.updateMyCartFragment(false);

                    }

                    Utils.vibrate(getActivity());

                }

            } else {

                Product tempObj = CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                        .get(subcategoryKey).get(productListNumber);

                if (CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                        .contains(tempObj)) {

                    int indexOfTempInShopingList = CenterRepository.getCenterRepository()
                            .getListOfProductsInShoppingList().indexOf(tempObj);

                    if (Integer.valueOf(tempObj.getQuantity()) != 0) {

                        CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                                .get(indexOfTempInShopingList)
                                .setQuantity(String.valueOf(Integer.valueOf(tempObj.getQuantity()) - 1));

                        ((ECartHomeActivity) getContext()).updateCheckOutAmount(
                                BigDecimal.valueOf(Long.valueOf(
                                        CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                                                .get(subcategoryKey).get(productListNumber).getSellMRP())),
                                false);

                        quanitity.setText(CenterRepository.getCenterRepository()
                                .getListOfProductsInShoppingList().get(indexOfTempInShopingList).getQuantity());

                        Utils.vibrate(getContext());

                        if (Integer.valueOf(
                                CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                                        .get(indexOfTempInShopingList).getQuantity()) == 0) {

                            CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                                    .remove(indexOfTempInShopingList);

                            ((ECartHomeActivity) getContext()).updateItemCount(false);

                        }

                    }

                } else {

                }

            }

        }

    });

    rootView.setFocusableInTouchMode(true);
    rootView.requestFocus();
    rootView.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {

                if (isFromCart) {

                    Utils.switchContent(R.id.frag_container, Utils.SHOPPING_LIST_TAG,
                            ((ECartHomeActivity) (getActivity())), AnimationType.SLIDE_UP);
                } else {

                    Utils.switchContent(R.id.frag_container, Utils.PRODUCT_OVERVIEW_FRAGMENT_TAG,
                            ((ECartHomeActivity) (getActivity())), AnimationType.SLIDE_RIGHT);
                }

            }
            return true;
        }
    });

    if (isFromCart) {

        similarProductsPager.setVisibility(View.GONE);

        topSellingPager.setVisibility(View.GONE);

    } else {
        showRecomondation();
    }

    return rootView;
}

From source file:com.grottworkshop.gwsspringindicator.SpringIndicator.java

@SuppressWarnings("deprecation")
private void addTabItems() {
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1.0f);
    tabs = new ArrayList<>();
    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 . java2  s  .c  o  m*/
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
        //TODO: getColor(int) is depreciated fix
        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.ingenia.fasttrack.SnackBar.MultilineSnackbar.java

/**
 * Set the action to be displayed in this {@link MultilineSnackbar}.
 *
 * @param text     Text to display//ww  w  .j av a  2 s.c  o  m
 * @param listener callback to be invoked when the action is clicked
 */
@NonNull
public MultilineSnackbar setAction(CharSequence text, final View.OnClickListener listener) {
    final TextView tv = mView.getActionView();

    if (TextUtils.isEmpty(text) || listener == null) {
        tv.setVisibility(View.GONE);
        tv.setOnClickListener(null);
    } else {
        tv.setVisibility(View.VISIBLE);
        tv.setText(text);
        tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                listener.onClick(view);
                // Now dismiss the
                dispatchDismiss(Callback.DISMISS_EVENT_ACTION);
            }
        });
    }
    return this;
}

From source file:com.semantive.waveformandroid.waveform.WaveformFragment.java

protected void loadGui(View view) {
    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    mDensity = metrics.density;//from  w  ww .  j  a  v a 2 s .c  om

    mMarkerLeftInset = (int) (46 * mDensity);
    mMarkerRightInset = (int) (48 * mDensity);
    mMarkerTopOffset = (int) (10 * mDensity);
    mMarkerBottomOffset = (int) (10 * mDensity);

    mStartText = (TextView) view.findViewById(R.id.starttext);
    mStartText.addTextChangedListener(mTextWatcher);
    mEndText = (TextView) view.findViewById(R.id.endtext);
    mEndText.addTextChangedListener(mTextWatcher);

    mPlayButton = (ImageButton) view.findViewById(R.id.play);
    mPlayButton.setOnClickListener(mPlayListener);
    mRewindButton = (ImageButton) view.findViewById(R.id.rew);
    mRewindButton.setOnClickListener(getRewindListener());
    mFfwdButton = (ImageButton) view.findViewById(R.id.ffwd);
    mFfwdButton.setOnClickListener(getFwdListener());

    TextView markStartButton = (TextView) view.findViewById(R.id.mark_start);
    markStartButton.setOnClickListener(mMarkStartListener);
    TextView markEndButton = (TextView) view.findViewById(R.id.mark_end);
    markEndButton.setOnClickListener(mMarkEndListener);

    enableDisableButtons();

    mWaveformView = (WaveformView) view.findViewById(R.id.waveform);
    mWaveformView.setListener(this);
    mWaveformView.setSegments(getSegments());

    mInfo = (TextView) view.findViewById(R.id.info);
    mInfo.setText(mCaption);

    mMaxPos = 0;
    mLastDisplayedStartPos = -1;
    mLastDisplayedEndPos = -1;

    if (mSoundFile != null && !mWaveformView.hasSoundFile()) {
        mWaveformView.setSoundFile(mSoundFile);
        mWaveformView.recomputeHeights(mDensity);
        mMaxPos = mWaveformView.maxPos();
    }

    mStartMarker = (MarkerView) view.findViewById(R.id.startmarker);
    mStartMarker.setListener(this);
    mStartMarker.setImageAlpha(255);
    mStartMarker.setFocusable(true);
    mStartMarker.setFocusableInTouchMode(true);
    mStartVisible = true;

    mEndMarker = (MarkerView) view.findViewById(R.id.endmarker);
    mEndMarker.setListener(this);
    mEndMarker.setImageAlpha(255);
    mEndMarker.setFocusable(true);
    mEndMarker.setFocusableInTouchMode(true);
    mEndVisible = true;

    updateDisplay();
}

From source file:com.ab.view.sliding.AbSlidingTabView2.java

/**
 * /*from w w  w .ja  va  2 s .  c  om*/
 * ??tab
 * @throws 
 */
public void addItemView(String tabText, Fragment fragment) {

    tabItemTextList.add(tabText);
    pagerItemList.add(fragment);

    tabItemList.clear();
    mTabLayout.removeAllViews();

    for (int i = 0; i < tabItemTextList.size(); i++) {
        final int index = i;
        String text = tabItemTextList.get(i);
        TextView tv = new TextView(this.context);
        tv.setTextColor(tabColor);
        tv.setTextSize(tabTextSize);
        tv.setText(text);
        tv.setGravity(Gravity.CENTER);
        tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1));
        tv.setPadding(12, 5, 12, 5);
        tv.setFocusable(false);
        tabItemList.add(tv);
        mTabLayout.addView(tv);
        tv.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                mViewPager.setCurrentItem(index);
            }
        });
    }

    //?
    Log.d(TAG, "addItemView finish");
    mFragmentPagerAdapter.notifyDataSetChanged();
    mViewPager.setCurrentItem(0);
    computeTabImg(0);
}