Example usage for android.widget TextView getText

List of usage examples for android.widget TextView getText

Introduction

In this page you can find the example usage for android.widget TextView getText.

Prototype

@ViewDebug.CapturedViewProperty
public CharSequence getText() 

Source Link

Document

Return the text that TextView is displaying.

Usage

From source file:com.abeo.tia.noordin.AddCaseStep2of4.java

public void addCaseListOfItems() {

    RequestParams params = null;/*from w ww .  j  av  a2s  . co m*/
    params = new RequestParams();

    RestService.post(METHOD_ADDCASE_ITEMLIST, params, new BaseJsonHttpResponseHandler<String>() {

        @Override
        public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) {
            // TODO Auto-generated method stub
            System.out.println(arg3);

        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) {
            // TODO Auto-generated method stub
            System.out.println("Add Case List Item Success Details ");
            System.out.println(arg2);

            try {

                arrayResponse = new JSONArray(arg2);
                // Create new list
                jsonItemList = new ArrayList<HashMap<String, String>>();

                for (int i = 0; i < arrayResponse.length(); i++) {

                    jsonResponse = arrayResponse.getJSONObject(i);

                    itemCode = jsonResponse.getString("ItemCode").toString();
                    itemName = jsonResponse.getString("ItemName").toString();

                    // SEND JSON DATA INTO SPINNER TITLE LIST
                    HashMap<String, String> addCaseItemList = new HashMap<String, String>();

                    // Send JSON Data to list activity
                    System.out.println("SEND ADD CASE ITEM LIST");
                    addCaseItemList.put("ItemCode_T", itemCode);
                    System.out.println(itemCode);
                    addCaseItemList.put("ItemName_T", itemName);
                    System.out.println(itemName);
                    System.out.println(" END ADD CASE ITEM LIST");

                    jsonItemList.add(addCaseItemList);
                    System.out.println("JSON ADD CASE ITEM LIST");
                    System.out.println(jsonItemList);
                }

            } catch (JSONException e) { // TODO Auto-generated
                // catch
                // block
                e.printStackTrace();
            }
            //Toast.makeText(AddCaseStep2of4.this, "AddCase Item Found", Toast.LENGTH_SHORT).show();
            dialog.dismiss();
            // Simple Adapter for List
            SimpleAdapter simpleAdapter = new SimpleAdapter(AddCaseStep2of4.this, jsonItemList,
                    R.layout.listview_column_addcase_itemlist, new String[] { "ItemCode_T", "ItemName_T" },
                    new int[] { R.id.listAddCaseHeader_ItemCodeText, R.id.listAddCaseHeader_ItemNameText });

            listViewItem.setAdapter(simpleAdapter);

            listViewItem.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                View ls = null;

                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                    if (get() != view && get() != null) {
                        get().setActivated(false);
                    }
                    //Toast.makeText(AddCaseStep2of4.this, "You Clicked at " + jsonItemList.get(position),
                    //   Toast.LENGTH_SHORT).show();
                    System.out.println(position);

                    //int mSelectedItem = position;      

                    view.setActivated(true);

                    // Get list of Item data
                    TextView c = (TextView) view.findViewById(R.id.listAddCaseHeader_ItemCodeText);
                    itemCode = c.getText().toString();
                    System.out.println(itemCode);

                    TextView D = (TextView) view.findViewById(R.id.listAddCaseHeader_ItemNameText);
                    itemName = D.getText().toString();

                    String data = (String) parent.getItemAtPosition(position).toString();
                    System.out.println(data);
                    set(view);

                    //store itemname and code in session
                    SharedPreferences prefLogin = getSharedPreferences("ItemData", Context.MODE_PRIVATE);

                    // We need an editor object to make changes
                    SharedPreferences.Editor edit = prefLogin.edit();

                    // Set/Store data
                    edit.putString("ItemCode", itemCode);
                    edit.putString("ItemName", itemName);
                    // Commit the changes
                    edit.commit();

                }

                private void set(View view) {
                    ls = view;
                }

                private View get() {
                    return ls;
                }
            });

            spinnerpropertyPROJECT.setSelection(2);
        }

        @Override
        protected String parseResponse(String arg0, boolean arg1) throws Throwable {

            // Get Json response
            arrayResponse = new JSONArray(arg0);
            jsonResponse = arrayResponse.getJSONObject(0);

            System.out.println("Add Case List Itemparse ParseResponse");
            System.out.println(arg0);
            return null;
        }
    });

}

From source file:com.atomjack.vcfp.VideoControllerView.java

private void initControllerView(View v) {
    mPauseButton = (ImageButton) v.findViewById(R.id.pause);
    if (mPauseButton != null) {
        mPauseButton.requestFocus();//  w  w w .j  a v a 2s  . c  o  m
        mPauseButton.setOnClickListener(mPauseListener);
    }

    mFullscreenButton = (ImageButton) v.findViewById(R.id.fullscreen);
    if (mFullscreenButton != null) {
        mFullscreenButton.requestFocus();
        mFullscreenButton.setOnClickListener(mFullscreenListener);
    }

    mMediaOptionsButton = (ImageButton) v.findViewById(R.id.mediaOptions);
    if (mMediaOptionsButton != null) {
        mMediaOptionsButton.setOnClickListener(mMediaOptionsListener);
    }

    mMicButton = (ImageButton) v.findViewById(R.id.mic);
    if (mMicButton != null) {
        mMicButton.setOnClickListener(mMicListener);
    }

    mMediaControllerPosterContainer = (ViewGroup) v.findViewById(R.id.mediaControllerPosterContainer);
    mMediaControllerPosterContainer.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            mPlayer.onPosterContainerTouch(v, event);
            return true;
        }
    });

    mFfwdButton = (ImageButton) v.findViewById(R.id.ffwd);
    if (mFfwdButton != null) {
        mFfwdButton.setOnClickListener(mFfwdListener);
        if (!mFromXml) {
            mFfwdButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
        }
    }

    mRewButton = (ImageButton) v.findViewById(R.id.rew);
    if (mRewButton != null) {
        mRewButton.setOnClickListener(mRewListener);
        if (!mFromXml) {
            mRewButton.setVisibility(mUseFastForward ? View.VISIBLE : View.GONE);
        }
    }

    mStopButton = (ImageButton) v.findViewById(R.id.stop);
    if (mStopButton != null) {
        mStopButton.setOnClickListener(mStopListener);
    }

    // By default these are hidden. They will be enabled when setPrevNextListeners() is called
    mNextButton = (ImageButton) v.findViewById(R.id.next);
    if (mNextButton != null && !mFromXml && !mListenersSet) {
        mNextButton.setVisibility(View.GONE);
    }
    mPrevButton = (ImageButton) v.findViewById(R.id.prev);
    if (mPrevButton != null && !mFromXml && !mListenersSet) {
        mPrevButton.setVisibility(View.GONE);
    }

    mPoster = (ImageView) v.findViewById(R.id.poster);
    if (mPosterBitmap != null)
        mPoster.setImageBitmap(mPosterBitmap);

    mBitrateSpinner = (CustomSpinner) v.findViewById(R.id.bitrateSpinner);
    if (mBitrateSpinner != null) {

        mBitrateSpinner.getBackground().setColorFilter(ContextCompat.getColor(mContext, R.color.white),
                PorterDuff.Mode.SRC_ATOP);

        final ArrayList<String> list = new ArrayList<>(
                VoiceControlForPlexApplication.localVideoQualityOptions.keySet());
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, R.layout.bitrate_dropdown_item,
                list) {
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                TextView textView = (TextView) super.getView(position, convertView, parent);
                textView.setTextColor(ContextCompat.getColor(mContext, R.color.white));
                return textView;
            }

            @Override
            public View getDropDownView(int position, View convertView, ViewGroup parent) {
                TextView textView = (TextView) super.getDropDownView(position, convertView, parent);
                textView.setTextColor(ContextCompat.getColor(mContext,
                        textView.getText().equals(mCurrentVideoQuality) ? R.color.black : R.color.white));
                textView.setBackgroundColor(ContextCompat.getColor(mContext,
                        textView.getText().equals(mCurrentVideoQuality) ? R.color.white
                                : R.color.mediaControllerBackground));
                return textView;
            }
        };
        mBitrateSpinner.setAdapter(adapter);

        mBitrateSpinner.setSelection(list.indexOf(mCurrentVideoQuality), false);

        mBitrateSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                String item = list.get(position);
                // Only notify the activity if the bitrate clicked on is not the current one
                if (mBitrateChangeListener != null && !item.equals(mCurrentVideoQuality)) {
                    hide();
                    mBitrateChangeListener.onBitrateChange(item);
                }
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        mBitrateSpinner.setSpinnerEventsListener(new CustomSpinner.OnSpinnerEventsListener() {
            @Override
            public void onSpinnerOpened() {
                mBitrateSpinnerIsOpen = true;
            }

            @Override
            public void onSpinnerClosed() {
                mBitrateSpinnerIsOpen = false;
                // hide the controller after 3 seconds
                Message msg = mHandler.obtainMessage(FADE_OUT);
                mHandler.removeMessages(FADE_OUT);
                mHandler.sendMessageDelayed(msg, sDefaultTimeout);
            }
        });

    }

    mProgress = (SeekBar) v.findViewById(R.id.mediacontroller_progress);
    if (mProgress != null) {
        if (mProgress instanceof SeekBar) {
            SeekBar seeker = (SeekBar) mProgress;
            seeker.setOnSeekBarChangeListener(mSeekListener);
        }
        mProgress.setMax(1000);
    }

    mEndTime = (TextView) v.findViewById(R.id.time);
    mCurrentTime = (TextView) v.findViewById(R.id.time_current);
    mFormatBuilder = new StringBuilder();
    mFormatter = new Formatter(mFormatBuilder, Locale.getDefault());

    installPrevNextListeners();
}

From source file:com.amazonaws.cognito.sync.demo.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);

    Log.i(TAG, "onCreate");

    /**//from  w ww.j a  va 2 s  . co m
     * Initialize Facebook SDK
     */
    FacebookSdk.sdkInitialize(getApplicationContext());
    callbackManager = CallbackManager.Factory.create();

    //Twitter
    if (mOauthConsumer == null) {
        mOauthProvider = new DefaultOAuthProvider("https://api.twitter.com/oauth/request_token",
                "https://api.twitter.com/oauth/access_token", "https://api.twitter.com/oauth/authorize");
        mOauthConsumer = new DefaultOAuthConsumer(getString(R.string.twitter_consumer_key),
                getString(R.string.twitter_consumer_secret));
    }
    retrieveTwitterCredentials(getIntent());

    //If access token is already here, set fb session
    final AccessToken fbAccessToken = AccessToken.getCurrentAccessToken();
    if (fbAccessToken != null) {
        setFacebookSession(fbAccessToken);
        btnLoginFacebook.setVisibility(View.GONE);
    }

    /**
     * Initializes the sync client. This must be call before you can use it.
     */
    CognitoSyncClientManager.init(this);

    btnLoginFacebook = (Button) findViewById(R.id.btnLoginFacebook);
    btnLoginFacebook.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // start Facebook Login
            LoginManager.getInstance().logInWithReadPermissions(MainActivity.this,
                    Arrays.asList("public_profile"));
            LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                    btnLoginFacebook.setVisibility(View.GONE);
                    new GetFbName(loginResult).execute();
                    setFacebookSession(loginResult.getAccessToken());
                }

                @Override
                public void onCancel() {
                    Toast.makeText(MainActivity.this, "Facebook login cancelled", Toast.LENGTH_LONG).show();
                }

                @Override
                public void onError(FacebookException error) {
                    Toast.makeText(MainActivity.this, "Error in Facebook login " + error.getMessage(),
                            Toast.LENGTH_LONG).show();
                }
            });
        }
    });
    btnLoginFacebook.setEnabled(getString(R.string.facebook_app_id) != "facebook_app_id");

    try {
        mAuthManager = new AmazonAuthorizationManager(this, Bundle.EMPTY);
    } catch (IllegalArgumentException e) {
        Log.d(TAG, "Login with Amazon isn't configured correctly. " + "Thus it's disabled in this demo.");
    }
    btnLoginLWA = (Button) findViewById(R.id.btnLoginLWA);
    btnLoginLWA.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mAuthManager.authorize(APP_SCOPES, Bundle.EMPTY, new AuthorizeListener());
        }
    });
    btnLoginLWA.setEnabled(mAuthManager != null);

    Button btnWipedata = (Button) findViewById(R.id.btnWipedata);
    btnWipedata.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            new AlertDialog.Builder(MainActivity.this).setTitle("Wipe data?")
                    .setMessage("This will log off your current session and wipe all user data. "
                            + "Any data not synchronized will be lost.")
                    .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // clear login status
                            if (fbAccessToken != null) {
                                LoginManager.getInstance().logOut();
                            }
                            btnLoginFacebook.setVisibility(View.VISIBLE);
                            if (mAuthManager != null) {
                                mAuthManager.clearAuthorizationState(null);
                            }
                            btnLoginLWA.setVisibility(View.VISIBLE);
                            // wipe data
                            CognitoSyncClientManager.getInstance().wipeData();

                            // Wipe shared preferences
                            AmazonSharedPreferencesWrapper
                                    .wipe(PreferenceManager.getDefaultSharedPreferences(MainActivity.this));
                        }

                    }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.cancel();
                        }
                    }).show();
        }
    });

    findViewById(R.id.btnListDatasets).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, ListDatasetsActivity.class);
            startActivity(intent);
        }
    });

    btnLoginDevAuth = (Button) findViewById(R.id.btnLoginDevAuth);
    if ((CognitoSyncClientManager.credentialsProvider
            .getIdentityProvider()) instanceof DeveloperAuthenticationProvider) {
        btnLoginDevAuth.setEnabled(true);
        Log.w(TAG, "Developer authentication feature configured correctly. ");
    } else {
        btnLoginDevAuth.setEnabled(false);
        Log.w(TAG, "Developer authentication feature configured incorrectly. "
                + "Thus it's disabled in this demo.");
    }
    btnLoginDevAuth.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // username and password dialog
            final Dialog login = new Dialog(MainActivity.this);
            login.setContentView(R.layout.login_dialog);
            login.setTitle("Sample developer login");
            final TextView txtUsername = (TextView) login.findViewById(R.id.txtUsername);
            txtUsername.setHint("Username");
            final TextView txtPassword = (TextView) login.findViewById(R.id.txtPassword);
            txtPassword.setHint("Password");
            Button btnLogin = (Button) login.findViewById(R.id.btnLogin);
            Button btnCancel = (Button) login.findViewById(R.id.btnCancel);

            btnCancel.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    login.dismiss();
                }
            });

            btnLogin.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    // Validate the username and password
                    if (txtUsername.getText().toString().isEmpty()
                            || txtPassword.getText().toString().isEmpty()) {
                        new AlertDialog.Builder(MainActivity.this).setTitle("Login error")
                                .setMessage("Username or password cannot be empty!!").show();
                    } else {
                        // Clear the existing credentials
                        CognitoSyncClientManager.credentialsProvider.clearCredentials();
                        // Initiate user authentication against the
                        // developer backend in this case the sample Cognito
                        // developer authentication application.
                        ((DeveloperAuthenticationProvider) CognitoSyncClientManager.credentialsProvider
                                .getIdentityProvider()).login(txtUsername.getText().toString(),
                                        txtPassword.getText().toString(), MainActivity.this);
                    }
                    login.dismiss();
                }
            });
            login.show();
        }
    });

    /**
     * Button that leaves the app and launches the Twitter site to get an authorization.
     * If the user grants permissions to our app, it will be redirected to us again through
     * a callback.
     */
    Button btnLoginTwitter = (Button) findViewById(R.id.btnLoginTwitter);
    btnLoginTwitter.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        String callbackUrl = "callback://" + getString(R.string.twitter_callback_url);
                        String authUrl = mOauthProvider.retrieveRequestToken(mOauthConsumer, callbackUrl);
                        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl));
                        startActivity(intent);
                    } catch (Exception e) {
                        Log.w("oauth fail", e);
                    }
                }
            }).start();
        }
    });
    btnLoginTwitter.setEnabled(getString(R.string.twitter_consumer_secret) != "twitter_consumer_secret");

}

From source file:com.baseutil.strip.PagerSlidingTabStrip.java

private void updateTabTextColorStyles(int pos, int color, int unselectedcolor) {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            if (pos == i) {
                tab.setTextColor(color);
            } else {
                tab.setTextColor(unselectedcolor);
            }//from   ww  w  .  ja va2  s  . c o  m
            if (tabResources != null) {
                tab.setCompoundDrawablesWithIntrinsicBounds(tabResources[i], 0, 0, 0);
            }
            // setAllCaps() is only available from API 14, so the upper case
            // is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

From source file:com.bei.test.view.tab.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < mTabCount; i++) {
        View v = mTabsContainer.getChildAt(i);
        v.setBackgroundResource(mTabBackgroundResId);
        v.setPadding(mTabPadding, v.getPaddingTop(), mTabPadding, v.getPaddingBottom());
        TextView tab_title = (TextView) v.findViewById(R.id.psts_tab_title);
        if (tab_title != null) {
            tab_title.setTextColor(mTabTextColor);
            tab_title.setTypeface(mTabTextTypeface, mTabTextTypefaceStyle);
            //                tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTabNormalTextSize);
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (isTabTextAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString()
                            .toUpperCase(getResources().getConfiguration().locale));
                }/*from   ww w. j a  v a 2 s . c  o  m*/
            }
        }
    }
}

From source file:com.davidmascharka.lips.MainActivity.java

private void updateScanResults() {
    if (userInitiatedScan) {
        //Toast.makeText(this, "Scan finished", Toast.LENGTH_SHORT).show();

        resetWifiReadings(building);/*from  w w w  .  j  ava 2 s .  c  o  m*/

        scanResults = wifiManager.getScanResults();
        for (ScanResult result : scanResults) {
            if (wifiReadings.get(result.BSSID) != null) {
                wifiReadings.put(result.BSSID, result.level);
            } else { // BSSID wasn't programmed in - notify user
                //Toast.makeText(this, "This BSSID is new: " + result.BSSID,
                //      Toast.LENGTH_SHORT).show();
            }
        }

        // Get a filehandle for /sdcard/indoor_localization/dataset_BUILDING.txt
        File root = Environment.getExternalStorageDirectory();
        File dir = new File(root.getAbsolutePath() + "/indoor_localization");
        dir.mkdirs();
        File file = new File(dir, "dataset_" + building + ".txt");

        try {
            FileOutputStream outputStream = new FileOutputStream(file, true);
            PrintWriter writer = new PrintWriter(outputStream);

            writer.print(accelerometerX + "," + accelerometerY + "," + accelerometerZ + "," + magneticX + ","
                    + magneticY + "," + magneticZ + "," + light + "," + rotationX + "," + rotationY + ","
                    + rotationZ + "," + orientation[0] + "," + orientation[1] + "," + orientation[2]);

            for (String key : wifiReadings.keySet()) {
                writer.print("," + wifiReadings.get(key));
            }

            if (location != null) {
                writer.print("," + location.getLatitude() + "," + location.getLongitude() + ","
                        + location.getAccuracy());
            } else {
                //@author Mahesh Gaya added permission if-statment
                if (ActivityCompat.checkSelfPermission(this,
                        android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                        || ActivityCompat.checkSelfPermission(this,
                                android.Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
                        || ActivityCompat.checkSelfPermission(this,
                                android.Manifest.permission.CHANGE_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
                        || ActivityCompat.checkSelfPermission(this,
                                android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    Log.i(TAG, "Permissions have NOT been granted. Requesting permissions.");
                    requestMyPermissions();
                } else {
                    Log.i(TAG, "Permissions have already been granted. Getting last known location from GPS");
                    location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                }

                if (location != null) {
                    writer.print("," + location.getLatitude() + "," + location.getLongitude() + ","
                            + location.getAccuracy());
                } else {
                    //@author Mahesh Gaya added permission if-statment
                    if (ActivityCompat.checkSelfPermission(this,
                            android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                            || ActivityCompat.checkSelfPermission(this,
                                    android.Manifest.permission.ACCESS_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
                            || ActivityCompat.checkSelfPermission(this,
                                    android.Manifest.permission.CHANGE_WIFI_STATE) != PackageManager.PERMISSION_GRANTED
                            || ActivityCompat.checkSelfPermission(this,
                                    android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                        Log.i(TAG, "Permissions have NOT been granted. Requesting permissions.");
                        requestMyPermissions();
                    } else {
                        Log.i(TAG,
                                "Permssions have already been granted. Getting last know location from network");
                        location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    }

                    if (location != null) {
                        writer.print("," + location.getLatitude() + "," + location.getLongitude() + ","
                                + location.getAccuracy());
                    } else {
                        Toast.makeText(this, "Location was null", Toast.LENGTH_SHORT).show();
                        writer.print(",?,?,?");
                    }
                }
            }

            TextView xposition = (TextView) findViewById(R.id.text_xposition);
            TextView yposition = (TextView) findViewById(R.id.text_yposition);
            writer.print("," + xposition.getText().toString().substring(3));
            writer.print("," + yposition.getText().toString().substring(3));

            writer.print(" %" + (new Timestamp(System.currentTimeMillis())).toString());

            writer.print("\n\n");

            writer.flush();
            writer.close();

            Toast.makeText(this, "Done saving datapoint", Toast.LENGTH_SHORT).show();
            userInitiatedScan = false;
        } catch (Exception e) {
            Toast.makeText(this, "There was an error", Toast.LENGTH_SHORT).show();
            Log.e("ERROR", Log.getStackTraceString(e));
        }
    }

    Button button = (Button) findViewById(R.id.button_confirm);
    button.setClickable(true);
}

From source file:fiskinfoo.no.sintef.fiskinfoo.MyToolsFragment.java

private void setupRightArrowButton(final TextView headerDate, final String currentDate,
        final Button arrowRightButton) {
    arrowRightButton.setOnClickListener(new View.OnClickListener() {

        @Override// ww  w .j a v a2s.  c om
        public void onClick(View v) {
            if (headerDate.getText().toString().equals(currentDate)) {
                arrowRightButton.setVisibility(View.INVISIBLE);
            } else {
                String next = user.getToolLog().myLog.higherKey(headerDate.getText().toString());
                if (next != null) {
                    headerDate.setText(next);
                    if (headerDate.getText().toString().equals(currentDate)) {
                        arrowRightButton.setVisibility(View.INVISIBLE);
                    }
                } else {
                    headerDate.setText(currentDate);
                    arrowRightButton.setVisibility(View.INVISIBLE);
                }
            }
        }
    });
    if (headerDate.getText().toString().equals(currentDate)) {
        if (arrowRightButton.getVisibility() == View.VISIBLE) {
            arrowRightButton.setVisibility(View.INVISIBLE);
        }
    }
}

From source file:com.eall.installer.widget.PagerSlidingTabStrip.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            final TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            RippleDrawable.For(tab, getResources().getColor(R.color.color_primary));
            tab.setTextColor(tabTextColor);
            tab.setOnTouchListener(new OnTouchListener() {
                @Override//from w w  w . j  a  v  a2s . c o m
                public boolean onTouch(View v, MotionEvent event) {
                    return false;
                }
            });

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
            if (i == selectedPosition) {
                RippleDrawable.For(tab, getResources().getColor(R.color.color_primary_400));
                tab.setTextColor(selectedTabTextColor);
            }
        }
    }
}

From source file:com.chj.indicator.lib.TabSlidingIndicator.java

/**
 * ?//from  w  w  w.j a v  a2s.  c  o  m
 */
private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        // TODO:
        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            if (this.pager.getCurrentItem() == i) {
                // 
                tab.setTextColor(tabSelectedTextColor);
            } else {
                // 
                tab.setTextColor(tabNormalTextColor);
            }

            // setAllCaps() is only available from API 14, so the upper case
            // is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}

From source file:be.blinkt.openvpn.views.PagerSlidingTabStrip.java

private void updateTabStyles() {
    for (int i = 0; i < tabCount; i++) {
        View v = tabsContainer.getChildAt(i);
        v.setBackgroundResource(tabBackgroundResId);
        TextView tab_title = (TextView) v.findViewById(R.id.tab_title);

        if (tab_title != null) {
            tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab_title.setTypeface(tabTypeface,
                    pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
            if (tabTextColor != null) {
                tab_title.setTextColor(tabTextColor);
            }/*from   w  w  w.  j a va  2 s .  c  om*/
            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab_title.setAllCaps(true);
                } else {
                    tab_title.setText(tab_title.getText().toString().toUpperCase(locale));
                }
            }
        }
    }

}