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:me.willeponken.opendoor.AboutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    TextView aboutTitle = (TextView) findViewById(R.id.textViewAboutTitle);
    aboutTitle.setText(getString(R.string.general_app_name) + " " + BuildConfig.VERSION_NAME);
    aboutTitle.setOnClickListener(new View.OnClickListener() {
        @Override//from w ww  .ja  v  a 2s .  com
        public void onClick(View v) {
            onClickCount++;
            if (onClickCount >= 5) {
                onClickCount = 0;
                playEpicSaxGuy();
            }
        }
    });

    TextView licenseText = (TextView) findViewById(R.id.textViewAboutLicense);
    try {
        Resources resources = this.getResources();
        InputStream reader = resources.openRawResource(R.raw.license);

        byte[] bytes = new byte[reader.available()];
        if (reader.read(bytes) <= 0) {
            throw new IOException("Failed to read any data from file");
        }
        licenseText.setText(new String(bytes));
    } catch (IOException e) {
        licenseText.setText(getString(R.string.about_activity_error_no_license));
    }
}

From source file:com.plnyyanks.frcnotebook.activities.ViewMatch.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(PreferenceHandler.getTheme());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_match);

    activity = this;
    ActionBar bar = getActionBar();/*from w  ww . jav a 2  s. c  o  m*/
    bar.setTitle(parentEvent.getEventName() + " - " + parentEvent.getEventYear());
    bar.setSubtitle(eventKey);
    bar.setDisplayHomeAsUpEnabled(true);

    if (matchKey == null)
        return;

    if (PreferenceHandler.getTheme() == R.style.theme_dark) {
        ImageView nextMatch = (ImageView) findViewById(R.id.next_match);
        nextMatch.setBackgroundResource(R.drawable.ic_action_next_item_dark);
        ImageView prevMatch = (ImageView) findViewById(R.id.prev_match);
        prevMatch.setBackgroundResource(R.drawable.ic_action_previous_item_dark);
    }

    new GetNotesForMatch(this).execute(previousKey, matchKey, nextKey, eventKey);

    if (PreferenceHandler.getFMEnabled()) {
        TextView fieldMonitor = (TextView) findViewById(R.id.field_monitor_link);
        fieldMonitor.setVisibility(View.VISIBLE);
        fieldMonitor.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(activity, FieldMonitorActivity.class);
                startActivity(intent);
            }
        });
    }
}

From source file:edu.berkeley.boinc.attach.IndividualCredentialInputFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.attach_project_credential_input_dialog, container, false);

    TextView title = (TextView) v.findViewById(R.id.title);
    title.setText(projectName);/*from www. j a  v a  2  s .co m*/
    TextView message = (TextView) v.findViewById(R.id.message);
    message.setText(errorMessage);

    ArrayList<String> defaultValues = mListener.getDefaultInput();
    emailET = (EditText) v.findViewById(R.id.email_input);
    emailET.setText(defaultValues.get(0));
    nameET = (EditText) v.findViewById(R.id.name_input);
    nameET.setText(defaultValues.get(1));
    pwdET = (EditText) v.findViewById(R.id.pwd_input);

    Button loginButton = (Button) v.findViewById(R.id.login_button);
    loginButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Logging.DEBUG)
                Log.d(Logging.TAG, "IndividualCredentialInputFragment: login clicked");
            mListener.onFinish(project, true, emailET.getText().toString(), nameET.getText().toString(),
                    pwdET.getText().toString());
            dismiss();
        }
    });

    Button registerButton = (Button) v.findViewById(R.id.register_button);
    registerButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Logging.DEBUG)
                Log.d(Logging.TAG,
                        "IndividualCredentialInputFragment: register clicked, client account creation disabled: "
                                + project.config.clientAccountCreationDisabled);
            if (project.config.clientAccountCreationDisabled) {
                // cannot register in client, open website
                Intent i = new Intent(Intent.ACTION_VIEW);
                i.setData(Uri.parse(project.config.masterUrl));
                startActivity(i);
            } else {
                mListener.onFinish(project, false, emailET.getText().toString(), nameET.getText().toString(),
                        pwdET.getText().toString());
                dismiss();
            }
        }
    });

    TextView forgotPwdButton = (TextView) v.findViewById(R.id.forgotpwd_text);
    forgotPwdButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Logging.DEBUG)
                Log.d(Logging.TAG, "IndividualCredentialInputFragment: forgot pwd clicked");
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(forgotPwdLink));
            startActivity(i);
        }
    });

    CheckBox showPwdCb = (CheckBox) v.findViewById(R.id.show_pwd_cb);
    showPwdCb.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (((CheckBox) v).isChecked()) {
                pwdET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
            } else {
                pwdET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                pwdET.setTransformationMethod(PasswordTransformationMethod.getInstance());
            }
        }
    });

    return v;
}

From source file:com.flan.stock.fragment.FragmentQuotationHs.java

@Override
public void onStart() {
    super.onStart();

    //?ScrollView???
    /*scrollView.setOnTouchListener(new OnTouchListener() {
               /*  w w  w  .  j  a  va  2  s. c om*/
       @Override
       public boolean onTouch(View v, MotionEvent event) {
            
    if(event.getAction() == MotionEvent.ACTION_MOVE){
               
       if(event.getY()-scrollView.downY>10){
          //
          parentActivity.tabWidgetIsVisable(true);
       }else {
          //
          if(scrollView.getScrollY() - scrollView.scrollDownY > 10){
             parentActivity.tabWidgetIsVisable(false);
          }
       }
               
       System.out.println("scroll oy"+scrollView.scrollDownY+" ny="+scrollView.getScrollY());
    }
    v.performClick();
    return false;
       }
    });
    */

    zfbTitle.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (zfbIsClose) {
                Drawable drawable = getResources().getDrawable(R.drawable.label_expand);
                /// ??,??.
                drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                tv_zfb.setCompoundDrawables(drawable, null, null, null);
                nslv_zfb.setVisibility(View.VISIBLE);
                zfbIsClose = false;
            } else {
                Drawable drawable = getResources().getDrawable(R.drawable.label_close);
                /// ??,??.
                drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                tv_zfb.setCompoundDrawables(drawable, null, null, null);
                nslv_zfb.setVisibility(View.GONE);
                zfbIsClose = true;
            }
        }
    });

    TextView zfbMore = (TextView) zfbTitle.findViewById(R.id.hs_more);
    zfbMore.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context, HSAStockActivity.class);
            startActivity(intent);
        }
    });

}

From source file:io.github.hidroh.materialistic.DrawerActivity.java

@SuppressWarnings("ConstantConditions")
private void setUpDrawer() {
    mDrawerAccount.setOnClickListener(v -> showLogin());
    mDrawerLogout.setOnClickListener(v -> confirmLogout());
    View moreContainer = findViewById(R.id.drawer_more_container);
    TextView moreToggle = (TextView) findViewById(R.id.drawer_more);
    moreToggle.setOnClickListener(v -> {
        if (moreContainer.getVisibility() == View.VISIBLE) {
            moreToggle.setTextColor(ContextCompat.getColor(DrawerActivity.this,
                    AppUtils.getThemedResId(DrawerActivity.this, android.R.attr.textColorTertiary)));
            moreToggle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_expand_more_white_24dp, 0, 0, 0);
            moreContainer.setVisibility(View.GONE);
        } else {//w  ww  .  j a v  a 2  s  . c om
            moreToggle.setTextColor(ContextCompat.getColor(DrawerActivity.this,
                    AppUtils.getThemedResId(DrawerActivity.this, android.R.attr.textColorSecondary)));
            moreToggle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_expand_less_white_24dp, 0, 0, 0);
            moreContainer.setVisibility(View.VISIBLE);
        }
    });
    findViewById(R.id.drawer_list).setOnClickListener(v -> navigate(ListActivity.class));
    findViewById(R.id.drawer_best).setOnClickListener(v -> navigate(BestActivity.class));
    findViewById(R.id.drawer_popular).setOnClickListener(v -> navigate(PopularActivity.class));
    findViewById(R.id.drawer_new).setOnClickListener(v -> navigate(NewActivity.class));
    findViewById(R.id.drawer_show).setOnClickListener(v -> navigate(ShowActivity.class));
    findViewById(R.id.drawer_ask).setOnClickListener(v -> navigate(AskActivity.class));
    findViewById(R.id.drawer_job).setOnClickListener(v -> navigate(JobsActivity.class));
    findViewById(R.id.drawer_settings).setOnClickListener(v -> navigate(SettingsActivity.class));
    findViewById(R.id.drawer_favorite).setOnClickListener(v -> navigate(FavoriteActivity.class));
    findViewById(R.id.drawer_submit).setOnClickListener(v -> navigate(SubmitActivity.class));
    findViewById(R.id.drawer_user).setOnClickListener(v -> {
        Bundle extras = new Bundle();
        extras.putString(UserActivity.EXTRA_USERNAME, Preferences.getUsername(this));
        navigate(UserActivity.class, extras);
    });
    findViewById(R.id.drawer_feedback).setOnClickListener(v -> navigate(FeedbackActivity.class));

}

From source file:com.recursionlabs.thecommuter.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_about, container, false);

    mDrawerLayout = (DrawerLayout) rootView.findViewById(R.id.drawer_layout);
    AboutActivity.mDrawerLayout = mDrawerLayout;

    navigationView = (NavigationView) rootView.findViewById(R.id.nav_view);
    navigationView.getMenu().getItem(3).setChecked(true);

    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override//from  ww w  .  j  a v  a  2  s. c  om
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            menuItem.setChecked(true);
            int id = menuItem.getItemId();
            Intent intent;

            if (id == R.id.nav_favorites) {
                intent = new Intent(getActivity(), FavoritesActivity.class);
                startActivity(intent);
            } else if (id == R.id.nav_home) {
                intent = new Intent(getActivity(), MainActivity.class);
                startActivity(intent);
            } else if (id == R.id.nav_settings) {
                intent = new Intent(getActivity(), SettingsActivity.class);
                startActivity(intent);
            }

            mDrawerLayout.closeDrawers();
            return true;
        }
    });

    TextView international = (TextView) rootView.findViewById(R.id.international_4_0);
    international.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setData(Uri.parse("https://creativecommons.org/licenses/by-sa/4.0/deed.en"));
            startActivity(intent);
        }
    });

    TextView unported = (TextView) rootView.findViewById(R.id.unported_3_0);
    unported.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setData(Uri.parse("https://creativecommons.org/licenses/by-sa/3.0/deed.en"));
            startActivity(intent);
        }
    });

    TextView generic_2_5 = (TextView) rootView.findViewById(R.id.generic_2_5);
    generic_2_5.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setData(Uri.parse("https://creativecommons.org/licenses/by-sa/2.5/deed.en"));
            startActivity(intent);
        }
    });

    TextView generic_2_0 = (TextView) rootView.findViewById(R.id.generic_2_0);
    generic_2_0.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setData(Uri.parse("https://creativecommons.org/licenses/by-sa/2.0/deed.en"));
            startActivity(intent);
        }
    });

    TextView generic_1_0 = (TextView) rootView.findViewById(R.id.generic_1_0);
    generic_1_0.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setData(Uri.parse("https://creativecommons.org/licenses/by-sa/1.0/deed.en"));
            startActivity(intent);
        }
    });

    Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
    if (toolbar != null) {
        toolbar.setTitle("About");
        ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
        ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        ((AppCompatActivity) getActivity()).getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_hamburger);
    }

    return rootView;
}

From source file:com.kubotaku.android.code4kyoto5374.fragments.NotifySettingsDialogFragment.java

private void setupViews() {
    final View view = getView();

    final TextView alarmTime = (TextView) view.findViewById(R.id.alarm_text_time);
    alarmTime.setText(this.alarm.toString());
    alarmTime.setOnClickListener(onClickAlarmTimeListener);

    final Switch alarmSwitch = (Switch) view.findViewById(R.id.alarm_switch);
    alarmSwitch.setChecked(this.alarm.enable);
    alarmSwitch.setOnCheckedChangeListener(onCheckedChangeListener);
}

From source file:kiv.janecekz.ma.ToneFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View root = inflater.inflate(R.layout.tone, container, false);
    RelativeLayout space = (RelativeLayout) root.findViewById(R.id.sunspace);
    space.setOnTouchListener(TouchControl.getInstance());

    circle = (ImageView) root.findViewById(R.id.circle);

    inAnim = TouchControl.getAnimation(TouchControl.ANIMATION_IN, 300);
    outAnim = TouchControl.getAnimation(TouchControl.ANIMATION_OUT, 300);

    input = (EditText) root.findViewById(R.id.tone_value_edit);
    input.setOnEditorActionListener(this);

    TextView sharp = (TextView) root.findViewById(R.id.sharp);
    sharp.setOnClickListener(this);

    ViewGroup defList = (ViewGroup) root.findViewById(R.id.tone_list);
    for (int i = 0; i < defList.getChildCount(); i++) {
        TextView v = (TextView) defList.getChildAt(i);
        v.setOnClickListener(this);
    }/*from w  w  w.java2s .  c  o  m*/
    return root;
}

From source file:com.sbhstimetable.sbhs_timetable_android.NoticesFragment.java

@Override
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    if (!ApiAccessor.isLoggedIn()) {
        View v = inflater.inflate(R.layout.fragment_pls2login, container, false);
        TextView t = (TextView) v.findViewById(R.id.textview);
        t.setOnClickListener(new View.OnClickListener() {
            @Override/*from  w ww . j a v  a  2  s  .  c  om*/
            public void onClick(View view) {
                Intent i = new Intent(container.getContext(), LoginActivity.class);
                container.getContext().startActivity(i);
            }
        });
        return v;
    }
    final SwipeRefreshLayout res = (SwipeRefreshLayout) inflater.inflate(R.layout.fragment_notices, container,
            false);
    this.layout = res;
    final ListView v = (ListView) res.findViewById(R.id.notices_listview);
    v.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {
        }

        @Override
        public void onScroll(AbsListView absListView, int i, int i2, int i3) {
            int topRowVerticalPosition = (v == null || v.getChildCount() == 0) ? 0 : v.getChildAt(0).getTop();
            res.setEnabled(topRowVerticalPosition >= 0);
        }
    });
    final Context c = this.getActivity();
    res.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refreshing = true;
            ApiAccessor.getBelltimes(c, false);
            ApiAccessor.getNotices(c, false);
            ApiAccessor.getToday(c, false);
        }
    });
    if (ThemeHelper.isBackgroundDark()) {
        res.setProgressBackgroundColor(R.color.background_floating_material_dark);
    } else {
        res.setProgressBackgroundColor(R.color.background_floating_material_light);
    }
    res.setColorSchemeColors(getResources().getColor(R.color.blue), getResources().getColor(R.color.green),
            getResources().getColor(R.color.yellow), getResources().getColor(R.color.red));
    JsonObject o = StorageCache.getNotices(getActivity(), DateTimeHelper.getDateString(getActivity()));
    NoticesJson n = NoticesJson.getInstance();
    if (o != null) {
        n = new NoticesJson(o);
    }

    if (n != null) {
        NoticesAdapter a = new NoticesAdapter(n);
        this.adapter = a;
        v.setAdapter(a);
    }

    return res;
}

From source file:com.todoroo.astrid.welcome.tutorial.WelcomeWalkthrough.java

protected void setupLoginLater() {
    TextView loginLater = (TextView) currentView.findViewById(R.id.login_later);
    loginLater.setOnClickListener(loginLaterListener);
    loginLater.setVisibility(View.VISIBLE);
}