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:eu.iescities.pilot.rovereto.roveretoexplorer.custom.CommentsHandler.java

/**
 * @param ctx//from w w  w  .  jav a2  s  .  c  om
 * @param toggle
 * @param container
 */
public CommentsHandler(BaseDTObject object, FragmentActivity activity, View main) {
    super();
    this.activity = activity;
    this.main = main;

    TextView toggle = (TextView) main.findViewById(R.id.comments_tv);
    ImageView toggleButton = (ImageView) main.findViewById(R.id.comments_button);
    Button rateButton = (Button) main.findViewById(R.id.rate_button);
    this.object = object;

    OnClickListener commentsListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            commentsVisible = !commentsVisible;
            if (commentsVisible) {
                loadComments();
            }
        }
    };
    toggle.setOnClickListener(commentsListener);
    toggleButton.setOnClickListener(commentsListener);

    RatingBar rating = (RatingBar) main.findViewById(R.id.rating);
    rating.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                ratingDialog();
            }
            return true;
        }
    });
    rateButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ratingDialog();
        }
    });

    updateRating();
}

From source file:com.fullmeadalchemist.mustwatch.ui.batch.form.BatchFormFragment.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    if (viewModel.batch != null) {
        // We're in "edit" mode, so set the title accordingly
        FORM_MODE = MODES.EDIT;//from   w w w . j  a v  a2s .c o  m
        TextView formTitle = getActivity().findViewById(R.id.batchFormTitleTV);
        if (formTitle != null) {
            String title = getResources().getString(R.string.edit_batch_title);
            title = String.format(title, viewModel.batch.id);
            formTitle.setText(title);
        }
    } else {
        FORM_MODE = MODES.CREATE;
    }
    updateUiDateTime();

    TextView dateField = getActivity().findViewById(R.id.createDateDate);
    if (dateField != null) {
        dateField.setOnClickListener(v -> {
            Timber.i("Date was clicked!");
            DialogFragment newFragment = new DatePickerFragment();
            Bundle args = new Bundle();
            args.putInt(YEAR, viewModel.batch.createDate.get(Calendar.YEAR));
            args.putInt(MONTH, viewModel.batch.createDate.get(Calendar.MONTH));
            args.putInt(DAY_OF_MONTH, viewModel.batch.createDate.get(Calendar.DAY_OF_MONTH));
            newFragment.setArguments(args);
            newFragment.setTargetFragment(this, DATE_REQUEST_CODE);
            newFragment.show(getActivity().getSupportFragmentManager(), "datePicker");
        });
    }

    TextView timeField = getActivity().findViewById(R.id.createDateTime);
    if (timeField != null) {
        timeField.setOnClickListener(v -> {
            Timber.i("Time was clicked!");
            DialogFragment newFragment = new TimePickerFragment();
            Bundle args = new Bundle();
            args.putInt(HOUR, viewModel.batch.createDate.get(Calendar.HOUR));
            args.putInt(MINUTE, viewModel.batch.createDate.get(Calendar.MINUTE));
            newFragment.setArguments(args);
            newFragment.setTargetFragment(this, TIME_REQUEST_CODE);
            newFragment.show(getActivity().getSupportFragmentManager(), "timePicker");
        });
    }

    Button addSugarButton = getActivity().findViewById(R.id.add_sugar_button);
    if (addSugarButton != null) {
        addSugarButton.setOnClickListener(v -> {
            Timber.i("addSugarButton was clicked!");
            DialogFragment newFragment = new AddIngredientDialog();
            Bundle args = new Bundle();
            args.putString(INGREDIENT_TYPE, SUGAR.toString());
            newFragment.setArguments(args);
            newFragment.setTargetFragment(this, INGREDIENT_REQUEST_CODE);
            newFragment.show(getActivity().getSupportFragmentManager(), "sugarPicker");
        });
    }

    Button addNutrientButton = getActivity().findViewById(R.id.add_nutrient_button);
    if (addNutrientButton != null) {
        addNutrientButton.setOnClickListener(v -> {
            Timber.i("addNutrientButton was clicked!");
            DialogFragment newFragment = new AddIngredientDialog();
            Bundle args = new Bundle();
            args.putString(INGREDIENT_TYPE, NUTRIENT.toString());
            newFragment.setArguments(args);
            newFragment.setTargetFragment(this, INGREDIENT_REQUEST_CODE);
            newFragment.show(getActivity().getSupportFragmentManager(), "nutrientPicker");
        });
    }

    Button addYeastButton = getActivity().findViewById(R.id.add_yeast_button);
    if (addYeastButton != null) {
        addYeastButton.setOnClickListener(v -> {
            Timber.i("addYeastButton was clicked!");
            DialogFragment newFragment = new AddIngredientDialog();
            Bundle args = new Bundle();
            args.putString(INGREDIENT_TYPE, YEAST.toString());
            newFragment.setArguments(args);
            newFragment.setTargetFragment(this, INGREDIENT_REQUEST_CODE);
            newFragment.show(getActivity().getSupportFragmentManager(), "yeastPicker");
        });
    }

    Button addStabilizerButton = getActivity().findViewById(R.id.add_stabilizer_button);
    if (addStabilizerButton != null) {
        addStabilizerButton.setOnClickListener(v -> {
            Timber.i("addStabilizerButton was clicked!");
            DialogFragment newFragment = new AddIngredientDialog();
            Bundle args = new Bundle();
            args.putString(INGREDIENT_TYPE, STABILIZER.toString());
            newFragment.setArguments(args);
            newFragment.setTargetFragment(this, INGREDIENT_REQUEST_CODE);
            newFragment.show(getActivity().getSupportFragmentManager(), "stabilizerPicker");
        });
    }

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(datePickerMessageReceiver,
            new IntentFilter(DATE_SET_EVENT));
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(timePickerMessageReceiver,
            new IntentFilter(TIME_SET_EVENT));
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(ingredientPickerMessageReceiver,
            new IntentFilter(INGREDIENT_SET_EVENT));

    Button submitButton = getActivity().findViewById(R.id.button_submit);
    if (submitButton != null) {
        submitButton.setOnClickListener(v -> {
            Timber.i("Submit button clicked!");
            FORM_MODE = (viewModel.batch.id == null) ? MODES.CREATE : MODES.EDIT;
            viewModel.batch.name = dataBinding.name.getText().toString().trim();
            viewModel.batch.targetSgStarting = toDouble(
                    dataBinding.targetSgStarting.getText().toString().trim());
            viewModel.batch.targetSgFinal = toDouble(dataBinding.targetSgFinal.getText().toString().trim());
            viewModel.batch.targetABV = toFloat(dataBinding.targetABV.getText().toString().trim());
            viewModel.batch.startingPh = toFloat(dataBinding.startingPh.getText().toString().trim());
            viewModel.batch.startingTemp = toFloat(dataBinding.startingTemp.getText().toString().trim());

            viewModel.batch.outputVolume = toVolume(dataBinding.outputVolumeAmount.getText().toString(),
                    abbreviationMap.get(dataBinding.outputVolumeAmountUnit.getSelectedItem().toString()));

            viewModel.batch.status = BatchStatusEnum.fromString(dataBinding.status.getText().toString().trim());
            viewModel.batch.notes = dataBinding.notes.getText().toString().trim();

            if (FORM_MODE == MODES.CREATE) {
                Timber.d("We are in CREATE mode.");
                Timber.d("Current batch state:\n%s", viewModel.batch.toString());
                viewModel.saveNewBatch().observe(this, savedBatchId -> {
                    if (savedBatchId != null) {
                        Timber.i("Successfully saved Batch, which now has ID=%s", savedBatchId);
                        LocalBroadcastManager.getInstance(getActivity())
                                .unregisterReceiver(datePickerMessageReceiver);
                        LocalBroadcastManager.getInstance(getActivity())
                                .unregisterReceiver(timePickerMessageReceiver);
                        LocalBroadcastManager.getInstance(getActivity())
                                .unregisterReceiver(ingredientPickerMessageReceiver);
                        Snackbar snackbar = Snackbar.make(getActivity().findViewById(R.id.container),
                                "Saved batch!", Snackbar.LENGTH_LONG);
                        snackbar.show();
                        Answers.getInstance().logCustom(new CustomEvent("Batch create success"));
                        navigationController.navigateFromAddBatch(savedBatchId);
                    } else {
                        Answers.getInstance().logCustom(new CustomEvent("Batch create failed"));
                        Snackbar snackbar = Snackbar.make(getActivity().findViewById(R.id.container),
                                "Failed to save batch!", Snackbar.LENGTH_LONG);
                        snackbar.show();
                    }
                });
            } else {
                Timber.d("We are in EDIT mode for batch #%s", viewModel.batch.id);
                Timber.d("Current batch state:\n%s", viewModel.batch.toString());
                viewModel.updateBatch();
                LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(datePickerMessageReceiver);
                LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(timePickerMessageReceiver);
                LocalBroadcastManager.getInstance(getActivity())
                        .unregisterReceiver(ingredientPickerMessageReceiver);
                Snackbar snackbar = Snackbar.make(getActivity().findViewById(R.id.container), "Updated batch!",
                        Snackbar.LENGTH_LONG);
                snackbar.show();
                Answers.getInstance().logCustom(new CustomEvent("Batch edit success"));
                navigationController.navigateFromEditBatch(viewModel.batch.id);
            }

        });
    } else {
        Timber.e("Cannot find submit button in view");
    }
}

From source file:com.findhotel.widget.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);//from  w  w w  .java2 s.c o m
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);

}

From source file:com.grepsound.views.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);//from   w  ww  .j a v a 2s  .c  o  m
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);

}

From source file:com.ns.developer.tagview.widget.TagCloudLinkView.java

/**
 * tag draw//from  w  w  w. j a v a  2 s.c  o  m
 */
public void drawTags() {

    if (!mInitialized) {
        return;
    }

    // clear all tag
    removeAllViews();

    // layout padding left & layout padding right
    float total = getPaddingLeft() + getPaddingRight();
    // ???index
    int index = 1;
    // ?
    int pindex = index;

    // List Index
    int listIndex = 0;
    for (String item : mTags) {
        final int position = listIndex;
        final String tag = item;

        // inflate tag layout
        View tagLayout = (View) mInflater.inflate(R.layout.tag, null);
        tagLayout.setId(index);
        //            tagLayout.setBackgroundColor(mTagLayoutColor);

        // tag text
        TextView tagView = (TextView) tagLayout.findViewById(R.id.tag_txt);
        tagView.setText(tag);
        tagView.setPadding(INNER_VIEW_PADDING, INNER_VIEW_PADDING, INNER_VIEW_PADDING, INNER_VIEW_PADDING);
        tagView.setTextColor(mTagTextColor);
        tagView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mSelectListener != null) {
                    mSelectListener.onTagSelected(tag, position);
                }
            }
        });

        // calculateof tag layout width
        float tagWidth = tagView.getPaint().measureText(tag) + INNER_VIEW_PADDING * 2; // tagView padding (left & right)

        // deletable text
        TextView deletableView = (TextView) tagLayout.findViewById(R.id.delete_txt);
        if (mIsDeletable) {
            deletableView.setVisibility(View.VISIBLE);
            deletableView.setText(DEFAULT_DELETABLE_STRING);
            deletableView.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (mDeleteListener != null) {
                        String targetTag = tag;
                        TagCloudLinkView.this.remove(position);
                        mDeleteListener.onTagDeleted(targetTag, position);
                    }
                }
            });
            tagWidth += deletableView.getPaint().measureText(DEFAULT_DELETABLE_STRING) + INNER_VIEW_PADDING * 2; // deletableView Padding (left & right)
        } else {
            deletableView.setVisibility(View.GONE);
        }

        LayoutParams tagParams = new LayoutParams(HEIGHT_WC, HEIGHT_WC);
        tagParams.setMargins(0, 0, 0, 0);

        if (mWidth <= total + tagWidth + LAYOUT_WIDTH_OFFSET) {
            tagParams.addRule(RelativeLayout.BELOW, pindex);
            tagParams.topMargin = TAG_LAYOUT_TOP_MERGIN;
            // initialize total param (layout padding left & layout padding right)
            total = getPaddingLeft() + getPaddingRight();
            pindex = index;
        } else {
            tagParams.addRule(RelativeLayout.ALIGN_TOP, pindex);
            tagParams.addRule(RelativeLayout.RIGHT_OF, index - 1);
            if (index > 1) {
                tagParams.leftMargin = TAG_LAYOUT_LEFT_MERGIN;
                total += TAG_LAYOUT_LEFT_MERGIN;
            }
        }
        total += tagWidth;
        addView(tagLayout, tagParams);
        index++;
        listIndex++;
    }

    LayoutParams tagParams = new LayoutParams(HEIGHT_WC, HEIGHT_WC);
    tagParams.setMargins(0, 0, 0, 0);

    if (isAutoCompleteMode || !mIsDeletable) {
        return;
    }

    int tagWidth = 50; //25dp

    if (mWidth <= total + tagWidth + LAYOUT_WIDTH_OFFSET) {
        tagParams.addRule(RelativeLayout.BELOW, pindex);
        tagParams.topMargin = TAG_LAYOUT_TOP_MERGIN;
        // initialize total param (layout padding left & layout padding right)
        total = getPaddingLeft() + getPaddingRight();
        pindex = index;
    } else {
        tagParams.addRule(RelativeLayout.ALIGN_TOP, pindex);
        tagParams.addRule(RelativeLayout.RIGHT_OF, index - 1);
        if (index > 1) {
            tagParams.leftMargin = TAG_LAYOUT_LEFT_MERGIN;
            total += TAG_LAYOUT_LEFT_MERGIN;
        }
    }
    total += tagWidth;
    View tagLayout = (View) mInflater.inflate(R.layout.tag, null);
    addView(tagLayout, tagParams);
    tagLayout.findViewById(R.id.add_image_view).setVisibility(VISIBLE);
    tagLayout.findViewById(R.id.tag_txt).setVisibility(GONE);
    tagLayout.setClickable(true);
    tagLayout.setFocusable(true);
    tagLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mAddTagListener != null) {
                mAddTagListener.onAddTag();
            }
        }
    });
    int transparentColor = ContextCompat.getColor(getContext(), android.R.color.transparent);
    tagLayout.setBackgroundColor(transparentColor);

}

From source file:eu.trentorise.smartcampus.trentinofamiglia.custom.CommentsHandler.java

/**
 * @param ctx//from w w  w  .j a  v  a  2s  .  co m
 * @param toggle
 * @param container
 */
public CommentsHandler(BaseDTObject object, FragmentActivity activity, View main) {
    super();
    this.activity = activity;
    this.main = main;
    if (!CategoryHelper.hasRatingForm(object)) {
        main.findViewById(R.id.rating_block).setVisibility(View.GONE);
        return;
    }
    TextView toggle = (TextView) main.findViewById(R.id.comments_tv);
    ImageView toggleButton = (ImageView) main.findViewById(R.id.comments_button);
    Button rateButton = (Button) main.findViewById(R.id.rate_button);
    this.object = object;

    OnClickListener commentsListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            commentsVisible = !commentsVisible;
            if (commentsVisible) {
                loadComments();
            }
        }
    };
    toggle.setOnClickListener(commentsListener);
    toggleButton.setOnClickListener(commentsListener);

    RatingBar rating = (RatingBar) main.findViewById(R.id.rating);
    rating.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
                ratingDialog();
            }
            return true;
        }
    });
    rateButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ratingDialog();
        }
    });

    updateRating();
}

From source file:fr.shywim.antoinedaniel.ui.fragment.NewsFragment.java

public void fetchAntoinePosts() {
    mPostsAntoineLayout.removeView(mPostsAntoineLayout.findViewById(R.id.post_error));
    mPostsAntoineLayout.findViewById(R.id.progress).setVisibility(View.VISIBLE);
    Ion.with(mContext).load("http://antoine.shywim.fr/getfacebookposts").asJsonArray().withResponse()
            .setCallback(new FutureCallback<Response<JsonArray>>() {
                @Override/* w w  w .jav a 2 s  . co  m*/
                public void onCompleted(Exception e, Response<JsonArray> result) {
                    mPostsAntoineLayout.findViewById(R.id.progress).setVisibility(View.GONE);

                    int i = 0, j = 0;
                    if (e != null) {
                        e.printStackTrace();
                        Crashlytics.logException(e);
                        return;
                    }

                    JsonArray ja = result.getResult();
                    if (ja != null) {
                        while (i < 5 && j < ja.size()) {
                            JsonObject jo = ja.get(j).getAsJsonObject();

                            if (jo.get("story") == null) {
                                String name;
                                i++;
                                String message = jo.get("message") != null ? jo.get("message").getAsString()
                                        : "";
                                final String link = jo.get("link") != null ? jo.get("link").getAsString() : "";

                                if ("photo".equals(jo.get("type").getAsString())) {
                                    name = "Voir la photo sur Facebook";
                                } else {
                                    name = jo.get("name") != null ? jo.get("name").getAsString() : "";
                                }

                                View postCard = LayoutInflater.from(mContext).inflate(R.layout.post_antoine,
                                        mPostsAntoineLayout, false);
                                ((TextView) postCard.findViewById(R.id.message)).setText(message);
                                ((TextView) postCard.findViewById(R.id.name)).setText(name);
                                if (link != null && !link.isEmpty()) {
                                    postCard.findViewById(R.id.name)
                                            .setOnClickListener(new View.OnClickListener() {
                                                @Override
                                                public void onClick(View v) {
                                                    Intent intent = new Intent(Intent.ACTION_VIEW,
                                                            Uri.parse(link));
                                                    mContext.startActivity(intent);
                                                }
                                            });
                                }
                                ((TextView) postCard.findViewById(R.id.link)).setText(link);

                                mPostsAntoineLayout.addView(postCard);
                            }
                            j++;
                        }
                    } else {
                        TextView tv = (TextView) mPostsAntoineLayout.findViewById(R.id.post_error);
                        if (tv == null) {
                            tv = (TextView) LayoutInflater.from(mContext).inflate(R.layout.simple_textview,
                                    mPostsAntoineLayout, false);
                        }

                        tv.setText(
                                "Problme lors de la rception des donnes, " + "cliquez pour ressayer");
                        tv.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                fetchAntoinePosts();
                            }
                        });

                        mPostsAntoineLayout.addView(tv);
                    }
                }
            });
}

From source file:com.gh4a.fragment.RepositoryFragment.java

private void fillData() {
    TextView tvRepoName = (TextView) mContentView.findViewById(R.id.tv_repo_name);
    SpannableStringBuilder repoName = new SpannableStringBuilder();
    repoName.append(mRepository.getOwner().getLogin());
    repoName.append("/");
    repoName.append(mRepository.getName());
    repoName.setSpan(new IntentSpan(tvRepoName.getContext()) {
        @Override//from www.  j  a va  2s . c o m
        protected Intent getIntent() {
            return IntentUtils.getUserActivityIntent(getActivity(), mRepository.getOwner());
        }
    }, 0, mRepository.getOwner().getLogin().length(), 0);
    tvRepoName.setText(repoName);
    tvRepoName.setMovementMethod(UiUtils.CHECKING_LINK_METHOD);

    TextView tvParentRepo = (TextView) mContentView.findViewById(R.id.tv_parent);
    if (mRepository.isFork() && mRepository.getParent() != null) {
        Repository parent = mRepository.getParent();
        tvParentRepo.setVisibility(View.VISIBLE);
        tvParentRepo.setText(
                getString(R.string.forked_from, parent.getOwner().getLogin() + "/" + parent.getName()));
        tvParentRepo.setOnClickListener(this);
        tvParentRepo.setTag(parent);
    } else {
        tvParentRepo.setVisibility(View.GONE);
    }

    fillTextView(R.id.tv_desc, 0, mRepository.getDescription());
    fillTextView(R.id.tv_language, R.string.repo_language, mRepository.getLanguage());
    fillTextView(R.id.tv_url, 0, !StringUtils.isBlank(mRepository.getHomepage()) ? mRepository.getHomepage()
            : mRepository.getHtmlUrl());

    mContentView.findViewById(R.id.cell_stargazers).setOnClickListener(this);
    mContentView.findViewById(R.id.cell_forks).setOnClickListener(this);
    mContentView.findViewById(R.id.cell_pull_requests).setOnClickListener(this);
    mContentView.findViewById(R.id.tv_contributors_label).setOnClickListener(this);
    mContentView.findViewById(R.id.other_info).setOnClickListener(this);
    mContentView.findViewById(R.id.tv_releases_label).setOnClickListener(this);

    Permissions permissions = mRepository.getPermissions();
    updateClickableLabel(R.id.tv_collaborators_label, permissions != null && permissions.hasPushAccess());
    updateClickableLabel(R.id.tv_downloads_label, mRepository.isHasDownloads());
    updateClickableLabel(R.id.tv_wiki_label, mRepository.isHasWiki());

    TextView tvStargazersCount = (TextView) mContentView.findViewById(R.id.tv_stargazers_count);
    tvStargazersCount.setText(String.valueOf(mRepository.getWatchers()));

    TextView tvForksCount = (TextView) mContentView.findViewById(R.id.tv_forks_count);
    tvForksCount.setText(String.valueOf(mRepository.getForks()));

    LinearLayout llIssues = (LinearLayout) mContentView.findViewById(R.id.cell_issues);

    if (mRepository.isHasIssues()) {
        llIssues.setVisibility(View.VISIBLE);
        llIssues.setOnClickListener(this);
        // value will be filled when PR count arrives
    } else {
        llIssues.setVisibility(View.GONE);
    }

    mContentView.findViewById(R.id.tv_private)
            .setVisibility(mRepository.isPrivate() ? View.VISIBLE : View.GONE);

}

From source file:com.qubittech.feelknit.app.MainActivity.java

@Override
protected void onNavItemSelected(int id) {
    switch (id) {
    case 101://w  ww .  j  ava 2s  .  c  om
        ShowProfileFragment(ApplicationHelper.getAvatar(getApplicationContext()));
        break;
    case 102:
        ShowCurrentFeelingsFragment();
        break;
    case 103:
        StartUserFeelingsFragment();
        break;
    case 104:
        showCommentsFeelingsFragment();
        break;
    case 105:
        ShowRelatedFeelingFragment();
        break;
    case 106:
        final Dialog d = new Dialog(this, R.style.CustomDialogTheme);
        d.setContentView(R.layout.custom_dialog);
        d.show();

        TextView version = (TextView) d.findViewById(R.id.versionTextView);
        TextView saripaar = (TextView) d.findViewById(R.id.saripaar);
        TextView licenseLink = (TextView) d.findViewById(R.id.licenseLink);
        final TextView license = (TextView) d.findViewById(R.id.license);
        saripaar.setText(Html.fromHtml("<u>android-saripaar</u>"));
        licenseLink.setText(Html.fromHtml("(<u>license</u>)"));

        saripaar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Uri uriUrl = Uri.parse("https://github.com/ragunathjawahar/android-saripaar");
                Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
                startActivity(launchBrowser);
            }
        });

        license.setText("Copyright 2012 - 2015 Mobs and Geeks\n\n"
                + "Licensed under the Apache License, Version 2.0 (the \"License\");\n"
                + "you may not use this file except in compliance with the License.\n"
                + "You may obtain a copy of the License at\n" + "\n"
                + "    http://www.apache.org/licenses/LICENSE-2.0\n" + "\n"
                + "Unless required by applicable law or agreed to in writing, software\n"
                + "distributed under the License is distributed on an \"AS IS\" BASIS,\n"
                + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
                + "See the License for the specific language governing permissions and\n"
                + "limitations under the License.");
        licenseLink.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                license.setVisibility(license.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
            }
        });
        try {
            version.setText(getApplicationContext().getPackageManager()
                    .getPackageInfo(getApplicationContext().getPackageName(), 0).versionName);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        TextView close_btn = (TextView) d.findViewById(R.id.okButton);
        close_btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                d.dismiss();
            }
        });
    }
}

From source file:com.shenma.yueba.yangjia.activity.MainActivityForYangJia.java

/**
 * ?//from   w  ww.j a v  a2s  .  c  o  m
 */
private void initView() {
    TextView yangjia_msg_textview = (TextView) findViewById(R.id.yangjia_msg_textview);
    round_view = findViewById(R.id.round_view);
    registerBroadcase();
    //      yangjia_msg_textview.setOnClickListener(new OnClickListener() {
    //         
    //         @Override
    //         public void onClick(View v) {
    //            setRedView(false);
    //         }
    //      });
    TextView tv_center = (TextView) findViewById(R.id.tv_center);
    tv_center.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {//?
                //               showDialog();
                showBottomDialog();
            }
            return true;
        }
    });

    tv_center.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MainActivityForYangJia.this, "click", 1000).show();
        }
    });
    // TabHostTabHost
    mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
    // fragment
    int count = fragmentArray.length;
    for (int i = 0; i < count; i++) {
        // ?Tab?
        TabSpec tabSpec = mTabHost.newTabSpec(mTextviewArray[i]).setIndicator(getTabItemView(i));
        // TabTab?
        mTabHost.addTab(tabSpec, fragmentArray[i], null);
    }
    mTabHost.getTabWidget().setDividerDrawable(null); //tab
    mTabHost.setOnTabChangedListener(new OnTabChangeListener() {

        @Override
        public void onTabChanged(String tabId) {
            if (tabId.equals("?")) {
                setRedView(false);
            }
        }
    });
}