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.zql.android.clippings.device.view.MainActivity.java

private void initDrawer() {
    TextView paste = findViewById(R.id.paste);
    paste.setOnClickListener(new View.OnClickListener() {
        @Override/*from   ww w.ja  va2 s.c o  m*/
        public void onClick(View view) {
            mDrawerLayout.closeDrawer(Gravity.LEFT);
            Intent intent = new Intent(MainActivity.this, PasteActivity.class);
            startActivity(intent);
        }
    });
    TextView setting_hide = findViewById(R.id.setting_hide);
    setting_hide.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mDrawerLayout.closeDrawer(Gravity.LEFT);
            Intent intent = new Intent(MainActivity.this, HideClippingsActivity.class);
            startActivity(intent);
        }
    });
}

From source file:com.vose.fragment.action.RulesFragment.java

private void setTermsOfServiceView() {

    TextView termsView = (TextView) fRootView.findViewById(R.id.terms_of_service);

    termsView.setOnClickListener(new View.OnClickListener() {
        @Override//w  w w.  j  a v  a  2s . c o m
        public void onClick(View v) {

            setOnClickListener(getString(R.string.community_guidelines_title), getTermsOfServiceContents());

        }
    });

}

From source file:com.app.swaedes.swaedes.LoginPage.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login_page);

    //check if the gps is enabled or not
    GPSTracker gps = new GPSTracker(this);
    if (!gps.canGetLocation) {
        gps.showSettingsAlert();/*from  w  ww  . ja  va 2 s.  c o  m*/
    } else {
        Toast.makeText(LoginPage.this, "This app uses the gps to locate your position", Toast.LENGTH_LONG)
                .show();
    }

    Button btnSignIn = (Button) findViewById(R.id.button_signin);
    TextView btnSignUp = (TextView) findViewById(R.id.sign_up);

    //Views
    email = (EditText) findViewById(R.id.editText_login);
    password = (EditText) findViewById(R.id.editText_passwd);

    btnSignIn.setOnClickListener(this);
    btnSignUp.setOnClickListener(this);
}

From source file:com.vose.fragment.action.RulesFragment.java

private void setCommunityGuidelinesView() {

    TextView communityView = (TextView) fRootView.findViewById(R.id.community_guidelines);

    communityView.setOnClickListener(new View.OnClickListener() {
        @Override//from w ww.java  2  s  .  c  om
        public void onClick(View v) {
            setOnClickListener(getString(R.string.community_guidelines_title), getCommunityGuidelines());
        }
    });

}

From source file:de.devmil.common.ui.color.HistorySelectorView.java

private void makeColorList() {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout colorlist = (LinearLayout) findViewById(R.id.colorlist);

    if (colors == null || colors.length() <= 0) {
        View nocolors = findViewById(R.id.nocolors);
        nocolors.setVisibility(View.VISIBLE);
        colorlist.setVisibility(View.GONE);
        findViewById(R.id.colorlistscroll).setVisibility(View.GONE); //have to remove it's parent container too
        return;/*from   w ww . j a  v a2 s  .  c  om*/
    }
    try {
        for (int i = colors.length() - 1; i >= 0; i--) {
            final int color = colors.getInt(i);
            ViewGroup boxgroup = (ViewGroup) inflater.inflate(R.layout.color_historyview_item, colorlist,
                    false);
            TextView box = (TextView) boxgroup.findViewById(R.id.colorbox);
            box.setBackgroundColor(color);
            //box.setText("#"+Integer.toHexString(color));
            colorlist.addView(boxgroup);
            box.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    setColor(color);
                    onColorChanged();
                }
            });
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.github.tetravex_android.activity.SettingsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // Navigate up to app's home screen
        NavUtils.navigateUpFromSameTask(this);
        return true;
    case R.id.action_reset_scores:
        // reset the scores database
        DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
            @Override//w  w w  .java 2 s. c  o m
            public void onClick(DialogInterface dialog, int userChoice) {
                switch (userChoice) {
                case DialogInterface.BUTTON_POSITIVE:
                    // reset the scores database
                    deleteAllScores();
                    break;

                case DialogInterface.BUTTON_NEGATIVE:
                    break;
                }
            }
        };

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(getResources().getString(R.string.dialog_reset_scores_prompt));
        builder.setPositiveButton(getResources().getString(R.string.dialog_ok), dialogClickListener);
        builder.setNegativeButton(getResources().getString(R.string.dialog_cancel), dialogClickListener);
        builder.show();
        return true;
    case R.id.action_about:
        Dialog dialog = new Dialog(this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.dialog_about);

        TextView linkText = (TextView) dialog.findViewById(R.id.legal_link);
        linkText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SettingsActivity.this, LegalActivity.class);
                startActivity(intent);
            }
        });

        dialog.setCancelable(true);
        dialog.show();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.ibm.mil.readyapps.telco.onboarding.appintrolib.AppIntro.java

@Override
final protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    super.onCreate(savedInstanceState);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.intro_layout);

    final TextView skipButton = (TextView) findViewById(R.id.skip);
    final TextView nextButton = (TextView) findViewById(R.id.next);
    final TextView doneButton = (TextView) findViewById(R.id.done);

    skipButton.setOnClickListener(new View.OnClickListener() {
        @Override//from w ww  .  j a v a2  s .  c o  m
        public void onClick(@NonNull View v) {
            onSkipPressed();
        }
    });

    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(@NonNull View v) {
            pager.setCurrentItem(pager.getCurrentItem() + 1);
        }
    });

    doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(@NonNull View v) {
            onDonePressed();
        }
    });

    mPagerAdapter = new PagerAdapter(super.getSupportFragmentManager(), fragments);
    pager = (ViewPager) findViewById(R.id.view_pager);

    pager.setAdapter(this.mPagerAdapter);
    /**
     *  ViewPager.setOnPageChangeListener is now deprecated. Use addOnPageChangeListener() instead of it.
     */
    pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            if (slidesNumber > 1)
                mController.selectPosition(position);
            if (position == slidesNumber - 1) {
                skipButton.setVisibility(View.INVISIBLE);
                nextButton.setVisibility(View.GONE);
                doneButton.setVisibility(View.VISIBLE);
            } else {
                skipButton.setVisibility(View.VISIBLE);
                doneButton.setVisibility(View.GONE);
                nextButton.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    init(savedInstanceState);
    slidesNumber = fragments.size();

    if (slidesNumber == 1) {
        nextButton.setVisibility(View.GONE);
        doneButton.setVisibility(View.VISIBLE);
    } else {
        initController();
    }
}

From source file:org.geometerplus.android.fbreader.network.AuthenticationActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Thread.setDefaultUncaughtExceptionHandler(
            new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));
    setResult(RESULT_CANCELED);/*from w  ww.jav a  2s .co  m*/
    setContentView(R.layout.authentication);

    final Intent intent = getIntent();
    final String host = intent.getStringExtra(HOST_KEY);
    final String area = intent.getStringExtra(AREA_KEY);
    final String username = intent.getStringExtra(USERNAME_KEY);
    final String error = intent.getStringExtra(ERROR_KEY);
    final boolean showSignupLink = intent.getBooleanExtra(SHOW_SIGNUP_LINK_KEY, false);

    myResource = ZLResource.resource("dialog").getResource("AuthenticationDialog");

    setTitle(host != null ? host : myResource.getResource("title").getValue());

    if (area != null && !"".equals(area)) {
        findTextView(R.id.authentication_subtitle).setText(area);
    } else {
        findTextView(R.id.authentication_subtitle).setVisibility(View.GONE);
    }
    final TextView warningView = findTextView(R.id.authentication_unencrypted_warning);
    if ("https".equalsIgnoreCase(intent.getStringExtra(SCHEME_KEY))) {
        warningView.setVisibility(View.GONE);
    } else {
        warningView.setText(myResource.getResource("unencryptedWarning").getValue());
    }
    findTextView(R.id.authentication_username_label).setText(myResource.getResource("login").getValue());
    findTextView(R.id.authentication_password_label).setText(myResource.getResource("password").getValue());

    final TextView usernameView = findTextView(R.id.authentication_username);
    usernameView.setText(username);

    final TextView errorView = findTextView(R.id.authentication_error);
    if (error != null && !"".equals(error)) {
        errorView.setVisibility(View.VISIBLE);
        errorView.setText(error);
    } else {
        errorView.setVisibility(View.GONE);
    }

    if (showSignupLink) {
        findViewById(R.id.authentication_signup_box).setVisibility(View.VISIBLE);
        final TextView signupView = (TextView) findViewById(R.id.authentication_signup);
        signupView.setText(myResource.getResource("register").getValue());
        signupView.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                setResult(RESULT_SIGNUP);
                finish();
            }
        });
    } else {
        findViewById(R.id.authentication_signup_box).setVisibility(View.GONE);
    }

    final ZLResource buttonResource = ZLResource.resource("dialog").getResource("button");

    final Button okButton = findButton(R.id.authentication_ok_button);
    okButton.setText(buttonResource.getResource("ok").getValue());
    okButton.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View v) {
            final Intent data = new Intent();
            data.putExtra(USERNAME_KEY, usernameView.getText().toString());
            data.putExtra(PASSWORD_KEY, findTextView(R.id.authentication_password).getText().toString());
            setResult(RESULT_OK, data);
            finish();
        }
    });

    final Button cancelButton = findButton(R.id.authentication_cancel_button);
    cancelButton.setText(buttonResource.getResource("cancel").getValue());
    cancelButton.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });
}

From source file:com.sincere.kboss.UserInfoActivity.java

void initUI() {

    ImageView btnBack = (ImageView) findViewById(R.id.btnBack);
    btnBack.setOnClickListener(new View.OnClickListener() {
        @Override/*from w ww. java2  s  .  c  o  m*/
        public void onClick(View view) {
            //callApiSetIntro();
            returnBack(null);
        }
    });

    TextView btnConfirm = (TextView) findViewById(R.id.btnConfirm);
    btnConfirm.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            returnBack(null);
        }
    });

    lblWorkingArea = (TextView) findViewById(R.id.lblWorkingArea);
    lblWeekday = (TextView) findViewById(R.id.lblWeekday);
    lblHistoryYear = (TextView) findViewById(R.id.lblHistoryYear);
    lblJobs = (TextView) findViewById(R.id.lblJobs);
    edtIntro = (EditText) findViewById(R.id.edtIntro);
    llIntroNext = (LinearLayout) findViewById(R.id.llIntroNext);
    llIntroNext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            callApiSetIntro();
        }
    });
    lblBasicSecDate = (TextView) findViewById(R.id.lblBasicSecDate);
    lblPayType = (TextView) findViewById(R.id.lblPayType);
    lblCert = (TextView) findViewById(R.id.lblCert);
    lblBank = (TextView) findViewById(R.id.lblBank);

    pw = (ProgressWheel) findViewById(R.id.pwLoading);
    setupProgress(0);
}

From source file:it.imwatch.nfclottery.dialogs.WinnersListDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the Builder class for convenient dialog construction
    final Activity activity = getActivity();
    if (activity == null) {
        Log.e(TAG, "Not attached to Activity: cannot build dialog");
        return null;
    }//from  ww  w .  j a  v  a2  s . c om

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    mWinnersCursor = updateWinnersCursors();

    String[] inVal = new String[] { NFCMLContent.Geeks.Columns.NAME.getName(),
            NFCMLContent.Geeks.Columns.EMAIL.getName() };

    int[] outVal = new int[] { R.id.txt_name, R.id.txt_email };

    // Create the adapter and assign it to the list
    mWinnersAdapter = new SimpleCursorAdapter(getActivity(), R.layout.winners_row, mWinnersCursor, inVal,
            outVal);
    mWinnersAdapter.setViewBinder(new ContactsViewBinder());

    LayoutInflater inflater = LayoutInflater.from(activity);
    final View rootView = inflater.inflate(R.layout.winners_dialog_layout, null);
    if (rootView == null) {
        Log.e(TAG, "Cannot inflate the dialog layout!");
        return null;
    }

    ListView listView = (ListView) rootView.findViewById(R.id.list_winners);

    listView.setAdapter(mWinnersAdapter);
    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            showRevokeVictoryUi(position);
            return true;
        }
    });

    TextView emptyTxt = (TextView) rootView.findViewById(android.R.id.empty);
    emptyTxt.setOnClickListener(mClickListener);

    listView.setEmptyView(emptyTxt);
    builder.setView(rootView);

    mSwitcher = (ViewSwitcher) rootView.findViewById(R.id.switcher);

    Button btn_cancel = (Button) mSwitcher.findViewById(R.id.btn_cancel);
    btn_cancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            endRevokeVictory();
        }
    });

    Button btn_revoke = (Button) mSwitcher.findViewById(R.id.btn_revoke);
    btn_revoke.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            revokeVictory();
        }
    });

    Button btn_ok = (Button) mSwitcher.findViewById(android.R.id.button1);
    btn_ok.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            final Dialog thisDialog = WinnersListDialog.this.getDialog();
            if (thisDialog != null) {
                thisDialog.cancel();
            } else {
                Log.w(TAG, "Can't get the Dialog instance.");
            }
        }
    });

    // Create the AlertDialog object and return it
    return builder.create();
}