List of usage examples for android.widget TextView setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.github.topbottomsnackbar.TBSnackbar.java
/** * Set the action to be displayed in this {@link TBSnackbar}. * * @param text Text to display/*from w w w . j a va 2s . com*/ * @param listener callback to be invoked when the action is clicked */ @NonNull public TBSnackbar 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 TBSnackbar dispatchDismiss(Callback.DISMISS_EVENT_ACTION); } }); } return this; }
From source file:com.cybussolutions.wikki.afri_pay.SignUp.java
@SuppressLint("NewApi") @Override/*from w w w .j a va 2 s .com*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_up); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); android.support.v7.app.ActionBar ab = getSupportActionBar(); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Enable the Up button if (ab != null) { ab.setHomeAsUpIndicator(R.drawable.ic_back); ab.setDisplayHomeAsUpEnabled(true); ab.setTitle("Registration"); } // BugSenseHandler.initAndStartSession(this, "1c9ce82c"); // chromeHelpPopup = new ChromeHelpPopup(SignUp.this, "Password should contain capital and small alphabets, one number and one special character. Example: Cybus@12"); // SelectedDateView = (TextView) findViewById(R.id.DatePickerInput); // imageView=(ImageView)findViewById(R.id.signup_imageView); firstname = (EditText) findViewById(R.id.signup_firstName); lastname = (EditText) findViewById(R.id.signup_lastName); email = (EditText) findViewById(R.id.signup_email); mobile = (EditText) findViewById(R.id.signup_mobile); gender = (RadioGroup) findViewById(R.id.genderRG); gender.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.mrRB: { genderText = "Male"; title = "Mr"; break; } case R.id.missRB: { genderText = "Female"; title = "Miss"; break; } case R.id.mrsRB: { genderText = "Female"; title = "Mrs"; break; } default: { break; } } } }); // idNo=(EditText) findViewById(R.id.signup_idNum); /* buttonchoose=(Button) findViewById(R.id.uploadimage); buttonchoose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // openGallery(v); } });*/ try { Button b = (Button) findViewById(R.id.signup_register); if (b != null) { b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub submit(v); } }); } Button cancel = (Button) findViewById(R.id.signup_cancel); if (cancel != null) { cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { finish(); } }); } } catch (Exception e) { e.printStackTrace(); } /* doctype=(RadioGroup) findViewById(R.id.signup_doctype); doctype.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.signup_passport: value = "Passport"; typeid="5"; break; case R.id.signup_license: value = "Driving License"; typeid="4"; break; } } });*/ String COmpare = "United Kingdom"; CountriesObjects = new ArrayList<>(); CountriesName = new ArrayList<>(); DataBase DataBase = new DataBase(SignUp.this); CountriesObjects = DataBase.getCountriesDB(""); for (int i = 0; i < CountriesObjects.size(); i++) { CountriesName.add(CountriesObjects.get(i).getCountry_name()); } country = (Spinner) findViewById(R.id.signup_countries_spinner); ArrayAdapter adapter201 = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, CountriesName); country.setAdapter(adapter201); if (!COmpare.equals(null)) { int spinnerPosition = adapter201.getPosition(COmpare); country.setSelection(spinnerPosition); } country.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub // InputMethodManager inputMethodManager = (InputMethodManager) // getSystemService(Activity.INPUT_METHOD_SERVICE); // inputMethodManager.hideSoftInputFromWindow(getCurrentFocus() // .getWindowToken(), 0); return false; } }); country.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int pos, long arg3) { // TODO Auto-generated method stub countrycode = (TextView) findViewById(R.id.signup_code); countrycode.setText("+" + CountriesObjects.get(pos).getCalling_code()); countrycode.setEnabled(false); } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } }); // user_name = (EditText) findViewById(R.id.signup_userName); password = (EditText) findViewById(R.id.signup_password); re_password = (EditText) findViewById(R.id.signup_confirmpassword); re_password.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub EditText e = (EditText) findViewById(R.id.signup_password); String pass = e.getText().toString(); TextView d = (TextView) findViewById(R.id.matchPassword); if (!pass.contentEquals(s)) { d.setText("Passwords Do not Match"); d.setVisibility(View.VISIBLE); } else { d.setVisibility(View.GONE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); }
From source file:com.coolerfall.uiart.PagerSlidingTabStrip.java
/** add one number indicator tab */ private void addNumTab(final int position, String title, int num) { LinearLayout tab = new LinearLayout(getContext()); TextView titleText = new TextView(getContext()); TextView numText = new TextView(getContext()); titleText.setText(title);/* w w w .j ava 2s.c o m*/ titleText.setGravity(Gravity.CENTER); titleText.setSingleLine(); numText.setText(Integer.toString(num)); numText.setGravity(Gravity.CENTER); numText.setPadding(mNumPadding, 1, mNumPadding, 1); numText.setSingleLine(); /* if the number is 0, set invisible */ if (num == 0) { numText.setVisibility(View.GONE); } else { numText.setVisibility(View.VISIBLE); } tab.addView(titleText, 0, mDefaultTabLayoutParams); tab.addView(numText, 1, mNumLayoutParams); tab.setGravity(Gravity.CENTER); addTab(position, tab); }
From source file:com.matthewmitchell.peercoin_android_wallet.ui.WalletActivity.java
private void prepareBackupWalletDialog(final Dialog dialog) { final AlertDialog alertDialog = (AlertDialog) dialog; final EditText passwordView = (EditText) alertDialog.findViewById(R.id.export_keys_dialog_password); passwordView.setText(null);//from w w w.java 2s .co m final ImportDialogButtonEnablerListener dialogButtonEnabler = new ImportDialogButtonEnablerListener( passwordView, alertDialog); passwordView.addTextChangedListener(dialogButtonEnabler); final CheckBox showView = (CheckBox) alertDialog.findViewById(R.id.export_keys_dialog_show); showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(passwordView)); final TextView warningView = (TextView) alertDialog .findViewById(R.id.backup_wallet_dialog_warning_encrypted); Wallet wallet = application.getWallet(); if (wallet == null) { warningView.setVisibility(View.GONE); runAfterLoad(new Runnable() { @Override public void run() { warningView.setVisibility(application.getWallet().isEncrypted() ? View.VISIBLE : View.GONE); } }); } else warningView.setVisibility(wallet.isEncrypted() ? View.VISIBLE : View.GONE); }
From source file:com.elitise.appv2.Peripheral.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent I = getIntent();/*from w w w . j av a 2 s . c o m*/ name = I.getStringExtra("mBname"); batteryIdx = I.getIntExtra("idx", -1); if (!sNExist()) { String mSN = I.getStringExtra("mSN"); saveSN(mSN); } isTablet = isTabletDevice(); // FirebaseStorage storage = FirebaseStorage.getInstance(); // StorageReference storageRef = storage.getReference(); // FirebaseOptions opts = FirebaseApp.getInstance().getOptions(); // Log.e(TAG, "Bucket = " + opts.getStorageBucket()+"\n URL"+opts.getApplicationId()); //mDetetor = new GestureDetectorCompat(this, new MyGestureListener()); setContentView(R.layout.activity_peripherals); TextView demoText = (TextView) findViewById(R.id.demoText); if (mUser.getBatteriesList().get(batteryIdx).isDemo) { demoText.setVisibility(View.VISIBLE); demoText.bringToFront(); } else { demoText.setVisibility(View.INVISIBLE); } getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mBluetoothDevices = new HashSet<>(); mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); mBluetoothAdapter = mBluetoothManager.getAdapter(); sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); statusBar = (TextView) findViewById(R.id.statusBar); // boolean enableDiag = sharedPrefs.getBoolean(getString(R.string.pref_mode_key), false); // // if (!enableDiag) // mCurrentServiceFragment = new BatteryServiceFragment(); // else // mCurrentServiceFragment = new BatteryServiceDiagFragment(); if (savedInstanceState != null) { phoneFragment = (PhoneLayoutFragement) getSupportFragmentManager().findFragmentByTag("PHONE"); normalFragment = (BatteryServiceFragment) getSupportFragmentManager().findFragmentByTag("NORMAL"); diagFragment = (BatteryServiceDiagFragment) getSupportFragmentManager().findFragmentByTag("DIAG"); if (isTablet) { mCurrentServiceFragment = normalFragment; } else { mCurrentServiceFragment = phoneFragment; } } else { diagFragment = new BatteryServiceDiagFragment(); normalFragment = new BatteryServiceFragment(); phoneFragment = new PhoneLayoutFragement(); //mCurrentServiceFragment = normalFragment; Bundle bd = new Bundle(); bd.putString("mBname", name); bd.putInt("bIndex", batteryIdx); diagFragment.setArguments(bd); normalFragment.setArguments(bd); phoneFragment.setArguments(bd); if (isTablet) { mCurrentServiceFragment = normalFragment; getSupportFragmentManager().beginTransaction() .add(R.id.normal_fragment_container, normalFragment, "NORMAL") .add(R.id.diag_fragment_container, diagFragment, "DIAG").hide(diagFragment) .show(normalFragment).commit(); } else { mCurrentServiceFragment = phoneFragment; getSupportFragmentManager().beginTransaction() .add(R.id.phone_fragment_container, phoneFragment, "PHONE") .add(R.id.normal_fragment_container, normalFragment, "NORMAL") .add(R.id.diag_fragment_container, diagFragment, "DIAG").hide(diagFragment) .hide(normalFragment).show(phoneFragment).commit(); } mCurrentServiceFragment.setArguments(bd); } if (!mUser.getBatteriesList().get(batteryIdx).isBonded) { mBluetoothGattService = mCurrentServiceFragment.getBluetoothGattService(); } else { mBluetoothGattService = mCurrentServiceFragment.getBluetoothGattServiceCustom(); } mAdvSettings = new AdvertiseSettings.Builder().setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED) .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH).setConnectable(true).setTimeout(0) .build(); mAdvData = new AdvertiseData.Builder().setIncludeDeviceName(false).setIncludeTxPowerLevel(false) .addServiceUuid( mCurrentServiceFragment.getServiceUUID(mUser.getBatteriesList().get(batteryIdx).isBonded)) .build(); mScanResponse = new AdvertiseData.Builder().setIncludeDeviceName(true).setIncludeTxPowerLevel(true).build(); // Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar2); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(false); getSupportActionBar().setDisplayShowTitleEnabled(false); logoView = (Logo_pathsView) findViewById(R.id.logoBar); Context context = getApplicationContext(); // or activity.getApplicationContext() PackageManager packageManager = context.getPackageManager(); String packageName = context.getPackageName(); String myVersionName = "1.0.0"; // initialize String try { myVersionName = packageManager.getPackageInfo(packageName, 0).versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } logoView.setVersion(myVersionName); if (!mBluetoothAdapter.isMultipleAdvertisementSupported()) { new MaterialDialog.Builder(this).title("BLE ERROR") .content("Sorry, this device not support BLE peripheral mode").positiveText("CONFIRM") .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { finish(); } }); } }
From source file:com.example.ali.topcoderandroid.Activities.ChallengeDetailActivity.java
private void bindChallenge(ChallengeDetailModel challengeDetail) { try {//from w w w. j av a2 s . c om Spanned detailHtmlContent = Html.fromHtml(challengeDetail.getDetailedRequirements()); TextView tvDetailedRequirements = (TextView) findViewById(R.id.tvDetailedRequirements); tvDetailedRequirements.setText(detailHtmlContent); String challengeName = String.valueOf(challengeDetail.getChallengeName()); String[] techNameArr = challengeDetail.getTechnology(); String technologies = Arrays.toString(techNameArr).replace("[", "").replace("]", ""); String challengeType = challengeDetail.getChallengeType(); String currentPhaseName = challengeDetail.getCurrentPhaseName(); String registrationStartDate = DateTimeParser.ParseDateTime(challengeDetail.getPostingDate()); String registrationEndDate = DateTimeParser.ParseDateTime(challengeDetail.getRegistrationEndDate()); String submissionEndDate = DateTimeParser.ParseDateTime(challengeDetail.getSubmissionEndDate()); long[] prizes = challengeDetail.getPrize(); long reliabilityBonus = challengeDetail.getReliabilityBonus(); String submissionsCount = challenge.getNumSubmissions(); String registrantsCount = challenge.getNumRegistrants(); TextView tvChallengeName = (TextView) findViewById(R.id.tvChallengeName); TextView tvTechnologies = (TextView) findViewById(R.id.tvTechnologies); TextView tvChallengeType = (TextView) findViewById(R.id.tvChallengeType); TextView tvCurrentPhaseRemainingTime = (TextView) findViewById(R.id.tvCurrentPhaseRemainingTime); TextView tvCurrentPhaseName = (TextView) findViewById(R.id.tvCurrentPhaseName); TextView tvRegistrationStartDate = (TextView) findViewById(R.id.tvPostingDate); TextView tvRegistrationEndDate = (TextView) findViewById(R.id.tvRegistrationEndDate); TextView tvSubmissionEndDate = (TextView) findViewById(R.id.tvSubmissionEndDate); TextView tvFirstPrize = (TextView) findViewById(R.id.tvFirstPrize); TextView tvSecondPrize = (TextView) findViewById(R.id.tvSecondPrize); TextView tvThirdPrize = (TextView) findViewById(R.id.tvThirdPrize); TextView tvReliabilityBonus = (TextView) findViewById(R.id.tvReliabilityBonus); TextView tvSubmissionsCount = (TextView) findViewById(R.id.tvSubmissionsCount); TextView tvRegistrantsCount = (TextView) findViewById(R.id.tvRegistrantsCount); tvSubmissionsCount.setText(submissionsCount); tvRegistrantsCount.setText(registrantsCount); String bonus = getString(R.string.reliability_bonus); tvReliabilityBonus.setText(bonus + reliabilityBonus + "$"); if (prizes != null && prizes.length > 0) { try { tvSecondPrize.setVisibility(View.GONE); tvThirdPrize.setVisibility(View.GONE); Spanned first = Html.fromHtml("<b>1st:</b> " + String.valueOf(prizes[0]) + "$"); tvFirstPrize.setText(first); if (prizes.length >= 2) { Spanned second = Html.fromHtml("<b>2nd:</b> " + String.valueOf(prizes[1]) + "$"); tvSecondPrize.setText(second); tvSecondPrize.setVisibility(View.VISIBLE); } if (prizes.length == 3) { Spanned third = Html.fromHtml("<b>3rd:</b> " + String.valueOf(prizes[2]) + "$"); tvThirdPrize.setText(third); tvThirdPrize.setVisibility(View.VISIBLE); } } catch (Exception e) { } } //String totalPrize = "$" + challenge.getTotalPrize(); //TextView tvTotalPrize = (TextView) findViewById(R.id.tvTotalPrize); //tvTotalPrize.setText(totalPrize); tvTechnologies.setText(technologies); tvChallengeType.setText(challengeType); //take positive Long currentPhaseRemainingTime = Math.abs(challenge.getCurrentPhaseRemainingTime()); String currentPhaseRemainingTimeString = DateTimeParser .ParseSecondToDayAndHour(currentPhaseRemainingTime); tvCurrentPhaseRemainingTime.setText(currentPhaseRemainingTimeString); if (currentPhaseRemainingTime < 7200) { try { int color = ContextCompat.getColor(context, R.color.redColor); tvCurrentPhaseRemainingTime.setTextColor(color); //todo error prone? } catch (Exception e) { LogHelper.Log(e); } } tvCurrentPhaseName.setText(currentPhaseName); tvRegistrationStartDate.setText(registrationStartDate); tvRegistrationEndDate.setText(registrationEndDate); tvSubmissionEndDate.setText(submissionEndDate); tvChallengeName.setText(challengeName); } catch (Exception e) { LogHelper.Log(e); } }
From source file:com.affectiva.affdexme.MainActivity.java
/** * We check to make sure the device has a front-facing camera. * If it does not, we obscure the app with a notice informing the user they cannot * use the app./*from w w w . jav a 2 s. c o m*/ */ void determineCameraAvailability() { PackageManager manager = getPackageManager(); isFrontFacingCameraDetected = manager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT); isBackFacingCameraDetected = manager.hasSystemFeature(PackageManager.FEATURE_CAMERA); if (!isFrontFacingCameraDetected && !isBackFacingCameraDetected) { progressBar.setVisibility(View.INVISIBLE); pleaseWaitTextView.setVisibility(View.INVISIBLE); TextView notFoundTextView = (TextView) findViewById(R.id.not_found_textview); notFoundTextView.setVisibility(View.VISIBLE); } //set default camera settings SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); //restore the camera type settings String cameraTypeName = sharedPreferences.getString("cameraType", CameraDetector.CameraType.CAMERA_FRONT.name()); if (cameraTypeName.equals(CameraDetector.CameraType.CAMERA_FRONT.name())) { cameraType = CameraDetector.CameraType.CAMERA_FRONT; mirrorPoints = true; } else { cameraType = CameraDetector.CameraType.CAMERA_BACK; mirrorPoints = false; } }
From source file:com.justinbull.ichnaeachecker.MainActivity.java
public RequestHandle getIchnaeaLookup(final Snackbar snack) { Log.i(TAG, "getIchnaeaLookup: Looking up " + mSelectedCell); return IchnaeaRestClient.geolocate(mSelectedCell, new JsonHttpResponseHandler() { @Override/*from w ww. j a v a 2 s .co m*/ public void onSuccess(int statusCode, Header[] headers, JSONObject response) { try { Log.i(TAG, "onSuccess: Cell in database! Location is: " + response.get("location") + " for " + mSelectedCell); TextView text = (TextView) findViewById(R.id.topLevelText); assert text != null; text.setText("Cell " + mSelectedCell.getFriendlyCellIdentity() + " in database!"); TextView textLat = (TextView) findViewById(R.id.latitudeText); TextView textLng = (TextView) findViewById(R.id.longitudeText); TextView textAcurracy = (TextView) findViewById(R.id.accuracyText); assert textLat != null; assert textLng != null; assert textAcurracy != null; textLat.setText( "Latitude: " + Double.toString(response.getJSONObject("location").getDouble("lat"))); textLng.setText( "Longitude: " + Double.toString(response.getJSONObject("location").getDouble("lng"))); textAcurracy .setText("Accuracy: " + Double.toString(response.getDouble("accuracy")) + " meters"); textLat.setVisibility(View.VISIBLE); textLng.setVisibility(View.VISIBLE); textAcurracy.setVisibility(View.VISIBLE); Snackbar snackSuccess = Snackbar.make( snack.getView(), mSelectedCell.getCellType() + " Cell " + mSelectedCell.getFriendlyCellIdentity() + " in Ichnaea database!", Snackbar.LENGTH_LONG); snackSuccess.getView() .setBackgroundColor(ContextCompat.getColor(MainActivity.this, R.color.colorSuccess)); snackSuccess.show(); } catch (JSONException e) { e.printStackTrace(); } } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { try { if (statusCode == 404 && errorResponse.getJSONObject("error").getInt("code") == 404) { Log.i(TAG, "onFailure: Cell is not in database: " + mSelectedCell); TextView text = (TextView) findViewById(R.id.topLevelText); assert text != null; text.setText("NOT IN DATABASE!"); TextView textLat = (TextView) findViewById(R.id.latitudeText); TextView textLng = (TextView) findViewById(R.id.longitudeText); TextView textAcurracy = (TextView) findViewById(R.id.accuracyText); textLat.setVisibility(View.INVISIBLE); textLng.setVisibility(View.INVISIBLE); textAcurracy.setVisibility(View.INVISIBLE); } else { Toast.makeText(MainActivity.this, "Unknown error occurred", Toast.LENGTH_SHORT).show(); } } catch (JSONException e) { Toast.makeText(MainActivity.this, "Unknown error occurred", Toast.LENGTH_SHORT).show(); e.printStackTrace(); } snack.dismiss(); } @Override public void onCancel() { super.onCancel(); snack.dismiss(); } }); }
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
private boolean setView(int id, String packageName) { TextView donate = (TextView) findViewById(id); PackageManager pm = getPackageManager(); try {//from w w w. j ava 2s .c o m ApplicationInfo info = pm.getApplicationInfo(packageName, 0); if (!info.enabled) { return false; } CharSequence label = getLabel(pm, info); donate.setContentDescription(label); donate.setCompoundDrawablesWithIntrinsicBounds(null, cropDrawable(pm.getApplicationIcon(info)), null, null); donate.setText(label); donate.setClickable(true); donate.setOnClickListener(this); donate.setVisibility(View.VISIBLE); return true; } catch (PackageManager.NameNotFoundException e) { UILog.d("cannot find package " + packageName, e); return false; } }