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:ch.eitchnet.android.mabea.activity.SettingsFragment.java

/**
 * /*from   w w w  .  j a va 2s . c  om*/
 */
private String updateModel() {
    TextView textView;

    textView = (TextView) this.rootView.findViewById(R.id.settingMabeaName);
    String name = textView.getText().toString();
    if (name == null || name.isEmpty())
        return "Name is not set!";

    textView = (TextView) this.rootView.findViewById(R.id.settingMabeaUrl);
    String url = textView.getText().toString();
    if (url == null || url.isEmpty())
        return "url is not set!";

    textView = (TextView) this.rootView.findViewById(R.id.settingMabeaUsername);
    String username = textView.getText().toString();
    if (username == null || username.isEmpty())
        return "username is not set!";

    Setting setting = MabeaApplication.getContext().getSetting();
    setting.setName(name);
    setting.setUrl(url);
    setting.setUsername(username);

    return null;
}

From source file:kr.co.generic.wifianalyzer.wifi.ConnectionViewTest.java

@Test
public void testConnectionWithConnectionInformation() throws Exception {
    // setup/*from   www.  j a va  2s.c  om*/
    WiFiAdditional wiFiAdditional = withWiFiAdditional();
    WiFiDetail connection = withConnection(wiFiAdditional);
    withConnectionInformation(connection);
    withAccessPointDetailView(connection);
    // execute
    fixture.update(wiFiData);
    // validate
    WiFiConnection wiFiConnection = wiFiAdditional.getWiFiConnection();
    View view = mainActivity.findViewById(R.id.connection);
    assertEquals(wiFiConnection.getIpAddress(),
            ((TextView) view.findViewById(R.id.ipAddress)).getText().toString());
    TextView linkSpeedView = (TextView) view.findViewById(R.id.linkSpeed);
    assertEquals(View.VISIBLE, linkSpeedView.getVisibility());
    assertEquals(wiFiConnection.getLinkSpeed() + WifiInfo.LINK_SPEED_UNITS, linkSpeedView.getText().toString());
}

From source file:com.p2c.thelife.SettingsFragment.java

public boolean setUserProfile(View view) {

    // set the updated user record
    TextView textView = null;
    textView = (TextView) getActivity().findViewById(R.id.settings_first_name);
    String firstName = textView.getText().toString();
    textView = (TextView) getActivity().findViewById(R.id.settings_last_name);
    String lastName = textView.getText().toString();
    textView = (TextView) getActivity().findViewById(R.id.settings_email);
    String email = textView.getText().toString();
    textView = (TextView) getActivity().findViewById(R.id.settings_phone);
    String phone = textView.getText().toString();
    m_updatedUser = new UserModel(TheLifeConfiguration.getOwnerDS().getId(), firstName, lastName, email, phone,
            TheLifeConfiguration.getOwnerDS().getProvider());

    // call the server
    m_progressDialog = ProgressDialog.show(getActivity(), getResources().getString(R.string.waiting),
            getResources().getString(R.string.storing_account), true, true);
    Server server = new Server(getActivity());
    server.updateUserProfile(TheLifeConfiguration.getOwnerDS().getId(), firstName, lastName, email, phone,
            GCMSupport.getInstance().getRegistrationId(), // keep the current value
            this, "updateUserProfile");
    return true;//from   ww w.  j  a  v a2s . c o  m
}

From source file:com.vrem.wifianalyzer.wifi.accesspoint.ConnectionViewTest.java

@Test
public void testConnectionWithConnectionInformation() throws Exception {
    // setup/*from   w  w  w  .j  a v a 2s  . c  o m*/
    WiFiAdditional wiFiAdditional = withWiFiAdditional();
    WiFiDetail connection = withConnection(wiFiAdditional);
    when(settings.getConnectionViewType()).thenReturn(ConnectionViewType.COMPLETE);
    withConnectionInformation(connection);
    withAccessPointDetailView(connection, ConnectionViewType.COMPLETE.getAccessPointViewType());
    // execute
    fixture.update(wiFiData);
    // validate
    WiFiConnection wiFiConnection = wiFiAdditional.getWiFiConnection();
    View view = mainActivity.findViewById(R.id.connection);
    assertEquals(wiFiConnection.getIpAddress(),
            ((TextView) view.findViewById(R.id.ipAddress)).getText().toString());
    TextView linkSpeedView = (TextView) view.findViewById(R.id.linkSpeed);
    assertEquals(View.VISIBLE, linkSpeedView.getVisibility());
    assertEquals(wiFiConnection.getLinkSpeed() + WifiInfo.LINK_SPEED_UNITS, linkSpeedView.getText().toString());
}

From source file:com.example.deer.boochat.chat_room.BluetoothChatFragment.java

/**
 * Set up the UI and background operations for chat.
 *///w  w w  .  j  av a2 s . c o  m
private void setupChat() {

    // Initialize the array adapter for the conversation thread
    mConversationArrayAdapter = new ArrayAdapter<String>(getActivity(), R.layout.message);

    mConversationView.setAdapter(mConversationArrayAdapter);

    // Initialize the compose field with a listener for the return key
    mOutEditText.setOnEditorActionListener(mWriteListener);

    // Initialize the send button with a listener that for click events
    mSendButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Send a message using content of the edit text widget
            View view = getView();
            if (null != view) {
                TextView textView = (TextView) view.findViewById(R.id.edit_text_out);
                String message = textView.getText().toString();
                Bundle bundle = new Bundle();
                bundle.putString(BluetoothChatFragment.EXTRAS_ADVERTISE_DATA, message);
                mCallback.onSendMessage(bundle);
                //?
                mConversationArrayAdapter.add("Me:  " + message);
                //??? ??
                Send_btn = false;
                mSendButton.setEnabled(Send_btn);
                mOutStringBuffer.setLength(0);
                mOutEditText.setText(mOutStringBuffer);

            }
        }
    });

    // Initialize the buffer for outgoing messages
    mOutStringBuffer = new StringBuffer("");
}

From source file:com.android.nsboc.ComposeFragment.java

public CompoundButton.OnCheckedChangeListener getNextToggleListener(final LinearLayout complianceLayout) {
    return new CompoundButton.OnCheckedChangeListener() {
        @Override//w w  w . j a v  a 2s.  com
        public void onCheckedChanged(CompoundButton toggleButton, boolean isChecked) {
            if (isChecked) {

                mAnotherComplianceLayout = (LinearLayout) View.inflate(getActivity(),
                        R.layout.compliance_layout, null);

                TextView imagePickerLabel = (TextView) mAnotherComplianceLayout
                        .findViewById(R.id.violation_image_picker);
                imagePickerLabel.setText(imagePickerLabel.getText().toString().replace(" " + mSectionsCount,
                        " " + (mSectionsCount + 1)));

                EditText commentEditText = (EditText) mAnotherComplianceLayout
                        .findViewById(R.id.comment_edittext);
                commentEditText.setHint(commentEditText.getText().toString().replace(" " + mSectionsCount,
                        " " + (mSectionsCount + 1)));

                TextView isAnotherLabel = (TextView) mAnotherComplianceLayout
                        .findViewById(R.id.is_another_label);
                isAnotherLabel.setText(isAnotherLabel.getText().toString().replace((mSectionsCount + 1) + "?",
                        (mSectionsCount + 2) + "?"));

                ToggleButton anotherToggle = (ToggleButton) mAnotherComplianceLayout
                        .findViewById(R.id.compliance_toggle);
                anotherToggle.setOnCheckedChangeListener(getNextToggleListener(mAnotherComplianceLayout));

                complianceLayout.addView(mAnotherComplianceLayout);
                mSectionsCount++;
            } else {
                mSectionsCount--;
                mAnotherComplianceLayout.setVisibility(View.GONE);
            }
        }
    };
}

From source file:com.cloudbase.cbhelperdemo.LogScreen.java

@Override
public void onClick(View v) {
    TextView logLineText = (TextView) this.getView().findViewById(R.id.logLineText);
    TextView logCategory = (TextView) this.getView().findViewById(R.id.logCategoryText);
    Spinner logSeveritySpinner = (Spinner) this.getView().findViewById(R.id.logSeveritySpinner);

    String logSeverityString = logSeveritySpinner.getSelectedItem().toString();

    if (logLineText == null || logLineText.getText() == null) {
        Log.d("DEMOAPP", "Log line text is null");
        return;//from  w ww  .  j a  v a2 s  . co m
    }
    if (logCategory == null || logCategory.getText() == null) {
        Log.d("DEMOAPP", "Log category is null");
        return;
    }
    // call the log APIs from the shared CBHelper in the MainActivity
    MainActivity.helper.log(logLineText.getText().toString(), CBLogLevel.valueOf(logSeverityString),
            logCategory.getText().toString(), null, // no responder but we want to queue the call
            true);

}

From source file:cl.ipp.katbag.fragment.Pages.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mainActivity = (MainActivity) super.getActivity();
    v = inflater.inflate(R.layout.fragment_pages, container, false);
    mainActivity.supportInvalidateOptionsMenu();

    // rescues parameters
    Bundle bundle = getArguments();/*w w w.  j  ava 2  s  .co m*/
    if (bundle != null) {
        id_app = bundle.getLong("id_app");
    }

    notRegister = (TextView) v.findViewById(R.id.page_not_register);
    editMode = false;
    loadListView();

    pagesListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (!editMode) {
                TextView pageld = (TextView) view.findViewById(R.id.page_row_id);

                Bundle bundle = new Bundle();
                bundle.putLong("id_app", id_app);
                bundle.putLong("id_page", Long.valueOf(pageld.getText().toString()));
                bundle.putString("name_page", String.valueOf(position));

                mFragment = new OnePage();
                mFragment.setArguments(bundle);
                FragmentTransaction t = getActivity().getSupportFragmentManager().beginTransaction();
                t.replace(R.id.fragment_main_container, mFragment);
                t.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
                t.addToBackStack(mFragment.getClass().getSimpleName());
                t.commit();
            }
        }
    });

    return v;
}

From source file:au.com.wallaceit.reddinator.ViewAllSubredditsActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    global = ((GlobalObjects) getApplicationContext());
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }/*from   w  ww  . ja va  2s. c o m*/
    setContentView(R.layout.viewallsubreddit);
    // setup list view
    listview = getListView();
    listview.setTextFilterEnabled(true);
    listview.setEmptyView(findViewById(R.id.subredditload));
    listview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent = new Intent(); // update subreddit without adding to list
            intent.putExtra("subreddit", sreddits.get(position));
            setResult(RESULT_SET_SUBREDDIT, intent);
            finish();
        }
    });
    // get empty view text for easy access later
    emptyview = (TextView) findViewById(R.id.poploadtxt);
    // setup search buttons
    searchbox = (EditText) this.findViewById(R.id.searchbox);
    searchbox.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
                search(v.getText().toString());
            }
            return true;
        }

    });
    ImageView searchbtn = (ImageView) this.findViewById(R.id.searchbutton);
    searchbtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            String query = searchbox.getText().toString();
            if (!query.equals("")) {
                search(query);
            } else {
                new AlertDialog.Builder(ViewAllSubredditsActivity.this).setTitle("No Query")
                        .setMessage("Please enter something to search for").show();
            }
        }
    });
}

From source file:com.listomate.activities.AccountsActivity.java

/**
 * Sets up the 'connect' screen content.
 */// w w  w  . j  a v a 2 s.co  m
private void setConnectScreenContent() {
    List<String> accounts = getGoogleAccounts();
    if (accounts.size() == 0) {
        // Show a dialog and invoke the "Add Account" activity if requested
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(R.string.needs_account);
        builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
            }
        });
        builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        builder.setIcon(android.R.drawable.stat_sys_warning);
        builder.setTitle(R.string.attention);
        builder.show();
    } else {
        final ListView listView = (ListView) findViewById(R.id.select_account);
        listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts));
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setItemChecked(mAccountSelectedPosition, true);

        final Button connectButton = (Button) findViewById(R.id.connect);
        connectButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Register in the background and terminate the activity
                mAccountSelectedPosition = listView.getCheckedItemPosition();
                TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition);
                register((String) account.getText());
                finish();
            }
        });

        final Button exitButton = (Button) findViewById(R.id.exit);
        exitButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                finish();
            }
        });
    }
}