List of usage examples for android.widget EditText getText
@Override
public Editable getText()
From source file:asu.edu.msse.gpeddabu.moviedescriptions.AddMovie.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_movie); spinner = (Spinner) findViewById(R.id.genreET); getGenreList();/*w ww. j a v a 2 s . c o m*/ // Create an ArrayAdapter using the string array and a default spinner layout adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, genreArr); // Specify the layout to use when the list of choices appears adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinner.setAdapter(adapter); final EditText title = (EditText) findViewById(R.id.titleET); final Button addButton = (Button) findViewById(R.id.addButton); title.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (title.getText().toString().length() > 0) { addButton.setEnabled(true); } else { addButton.setEnabled(false); } } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (title.getText().toString().length() > 0) { addButton.setEnabled(true); } else { addButton.setEnabled(false); } } @Override public void afterTextChanged(Editable s) { if (title.getText().toString().length() > 0) { addButton.setEnabled(true); } else { addButton.setEnabled(false); } } }); }
From source file:net.nordist.lloydproof.LloydProofTest.java
public void testKeyingAndSavingCorrection() { int startCount = store.count(); final EditText editText = (EditText) activity.findViewById(R.id.current_text); activity.runOnUiThread(new Runnable() { public void run() { editText.requestFocus();/*from w w w . j a va 2 s . c om*/ } }); settleWait(); sendKeys("D O U B L E COMMA SPACE D O U B L E COMMA SPACE"); sendKeys("T O I L SPACE A N D SPACE B U B B L E"); assertEquals("double, double, toil and bubble", editText.getText().toString()); final Button saveButton = (Button) activity.findViewById(R.id.save_button); activity.runOnUiThread(new Runnable() { public void run() { saveButton.performClick(); } }); settleWait(); assertEquals("", editText.getText().toString()); assertEquals(startCount + 1, store.count()); store.deleteAll(); }
From source file:com.lovejoy777sarootool.rootool.dialogs.UnpackDialog.java
@Override public Dialog onCreateDialog(Bundle state) { final Activity a = getActivity(); // Set an EditText view to get user input final EditText inputf = new EditText(a); inputf.setHint(R.string.enter_name); inputf.setText(BrowserActivity.getCurrentlyDisplayedFragment().mCurrentPath + "/"); final AlertDialog.Builder b = new AlertDialog.Builder(a); b.setTitle(R.string.extractto);/*from ww w . ja v a2 s . c o m*/ b.setView(inputf); b.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String newpath = inputf.getText().toString(); dialog.dismiss(); if (ext.equals("zip")) { final UnZipTask task = new UnZipTask(a); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath); } else if (ext.equals("rar")) { final UnRarTask task = new UnRarTask(a); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath); } } }); b.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); return b.create(); }
From source file:edu.rowan.app.fragments.FoodCommentFragment.java
/** * Setup the view and set the button action when clicked *//* w w w. ja va 2 s . c om*/ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.food_comment_layout, container, false); Button submit = (Button) view.findViewById(R.id.commentButton); final EditText commentField = (EditText) view.findViewById(R.id.commentField); submit.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { hideKeyboard(commentField); JsonQueryManager jsonManager = JsonQueryManager.getInstance(getActivity()); Map<String, String> params = new HashMap<String, String>(); String comment = commentField.getText().toString(); comment = comment.replaceAll("<.*>", ""); userComment = comment; try { comment = java.net.URLEncoder.encode(comment, "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show(); } params.put(FoodRatingFragment.FOOD_ENTRY_ID, foodEntryId); params.put(FoodRatingFragment.USER_ID, userId); params.put(COMMENT_PARAM, comment); jsonManager.requestJson(FOOD_COMMENT_ADDR, params, FoodCommentFragment.this); } }); return view; }
From source file:cc.siara.csv_ml_demo.MainActivity.java
/** * Parses input from textbox and generates DDL/DML statements and sets to * output text box// www . ja va 2 s. c o m */ private void toDDLDML() { EditText etInput = (EditText) findViewById(R.id.etInput); MultiLevelCSVParser parser = new MultiLevelCSVParser(); Document doc = null; try { doc = parser.parseToDOM(new StringReader(etInput.getText().toString()), false); String ex_str = parser.getEx().get_all_exceptions(); if (ex_str.length() > 0) { Toast.makeText(getApplicationContext(), ex_str, Toast.LENGTH_LONG).show(); if (parser.getEx().getErrorCode() > 0) return; } StringBuffer out_str = new StringBuffer(); DBBind.generateDDL(parser.getSchema(), out_str); if (out_str.length() > 0) { out_str.append("\r\n"); DBBind.generate_dml_recursively(parser.getSchema(), doc.getDocumentElement(), "", out_str); } else { out_str.append("No schema"); } EditText etOutput = (EditText) findViewById(R.id.etOutput); etOutput.setText(out_str.toString()); //tfOutputSize.setText(String.valueOf(out_str.length())); } catch (IOException e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); e.printStackTrace(); } }
From source file:com.dodo.wbbshoutbox.codebot.MainActivity.java
public void send() { EditText Username = (EditText) findViewById(R.id.txtUsername); EditText Message = (EditText) findViewById(R.id.txtMessage); if (Username.getText().toString().trim().length() <= 0 && loggedIn == 0) { Username.requestFocus();/*w w w . j av a2 s . c om*/ Toast.makeText(this, "Du hast keinen Benutzernamen eingegeben!", Toast.LENGTH_SHORT).show(); return; } if (Message.getText().toString().trim().length() <= 0) { Message.requestFocus(); Toast.makeText(this, "Du hast keine Nachricht eingegeben!", Toast.LENGTH_SHORT).show(); return; } RequestParams params_send = new RequestParams(); params_send.put("message", Message.getText().toString()); if (loggedIn == 0) { params_send.put("username", Username.getText().toString() + " (App)"); } else { params_send.put("username", ""); } params_send.put("ajax", "1"); postRequest(baseUrl + "index.php?action=ShoutboxEntryAdd", params_send); }
From source file:com.clevertrail.mobile.findtrail.Activity_FindTrail_ByLocation.java
private int submitSearch() { double dSearchLat = 0; double dSearchLong = 0; double dSearchDistance = 0; if (!Utils.isNetworkAvailable(mActivity)) { return R.string.error_nointernetconnection; }//from w ww.j a v a 2 s . c om // is this searching by proximity RadioButton rbProximity = (RadioButton) findViewById(R.id.rbFindTrailByLocationProximity); if (rbProximity != null && rbProximity.isChecked()) { // search by proximity // do we have a location? if (currentLocation != null) { dSearchLat = currentLocation.getLatitude(); dSearchLong = currentLocation.getLongitude(); } else { return R.string.error_currentlocationnotfound; } } else { //searching by city EditText etCity = (EditText) findViewById(R.id.txtFindTrailByLocationCity); if (etCity != null) { String sCity = etCity.getText().toString(); if (sCity.compareTo("") != 0) { //get the json info about the location from google maps JSONObject json = getLocationInfo(sCity); if (json == null) { return R.string.error_couldnotconnecttogooglemaps; } else { //get the lat/lng from the geocoding result from google maps Point pt = getLatLong(json); if (pt != null) { dSearchLat = pt.dLat; dSearchLong = pt.dLng; } else { return R.string.error_googlecouldnotfindcity; } } } else { return R.string.error_entercityname; } } } //find out how far the search radius will be int nProximityPos = m_cbFindTrailByLocationProximity.getSelectedItemPosition(); switch (nProximityPos) { case 0: dSearchDistance = 5; break; case 1: dSearchDistance = 10; break; case 2: dSearchDistance = 25; break; case 3: dSearchDistance = 50; break; case 4: dSearchDistance = 100; break; } // search for the given lat/long/dist JSONArray trailListJSON = fetchTrailListJSON(dSearchLat, dSearchLong, dSearchDistance); //do we have a trails that fit the criteria? if (trailListJSON != null && trailListJSON.length() > 0) { int len = trailListJSON.length(); try { Object_TrailList.clearTrails(); for (int i = 0; i < len; ++i) { JSONObject trail = trailListJSON.getJSONObject(i); Object_TrailList.addTrailWithJSON(trail); } } catch (JSONException e) { return R.string.error_corrupttrailinfo; } Intent i = new Intent(mActivity, Activity_FindTrail_DisplayMap.class); mActivity.startActivity(i); } else { return R.string.error_notrailsfoundinsearchradius; } return 0; }
From source file:cc.siara.csv_ml_demo.MainActivity.java
/** * Converts XML in output text box back to csv_ml and sets to input text box *///from ww w . j a v a 2 s.c om private void xmlToCSV() { EditText etOutput = (EditText) findViewById(R.id.etOutput); Document doc = null; try { doc = DocumentBuilderFactory.newInstance().newDocumentBuilder() .parse(new InputSource(new StringReader(etOutput.getText().toString()))); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getApplicationContext(), "Could not parse. XML expected in Output text box", Toast.LENGTH_LONG).show(); return; } String out_str = Outputter.generate(doc); EditText etInput = (EditText) findViewById(R.id.etInput); etInput.setText(out_str.toString()); //tfInputSize.setText(String.valueOf(out_str.length())); }
From source file:com.emorym.android_pusher.PusherSampleActivity.java
/** Called when the activity is first created. */ @Override//from w w w . j a v a2 s. c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; setContentView(R.layout.main); // This Handler is going to deal with incoming messages mPusher = new Pusher(PUSHER_APP_KEY); mPusher.bindAll(new PusherCallback() { @Override public void onEvent(String eventName, JSONObject eventData) { Log.d("Pusher Message", "Any Channel: " + eventName + " - " + eventData.toString()); } }); // Setup some toggles to subscribe/unsubscribe from our 2 test channels final ToggleButton test1 = (ToggleButton) findViewById(R.id.toggleButton1); final ToggleButton test2 = (ToggleButton) findViewById(R.id.toggleButton2); final Button send = (Button) findViewById(R.id.send_button); test1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (test1.isChecked()) { Channel channel1 = mPusher.subscribe(PUSHER_CHANNEL_1); channel1.bind("message:received", new PusherCallback() { @Override public void onEvent(JSONObject eventData) { Log.d("Pusher Message", PUSHER_CHANNEL_1 + ":" + eventData.toString()); Toast.makeText(mContext, eventData.toString(), Toast.LENGTH_SHORT).show(); } }); } else { mPusher.unsubscribe(PUSHER_CHANNEL_1); } } }); test2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (test2.isChecked()) { Channel channel2 = mPusher.subscribe(PUSHER_CHANNEL_2); channel2.bindAll(new PusherCallback() { @Override public void onEvent(String eventName, JSONObject eventData) { Log.d("Pusher Message", PUSHER_CHANNEL_2 + ":" + eventName + " " + eventData.toString()); EditText eventDataField = (EditText) findViewById(R.id.event_data); eventDataField.setText(eventData.toString()); } }); } else { mPusher.unsubscribe(PUSHER_CHANNEL_2); } } }); send.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { EditText channelName = (EditText) findViewById(R.id.channel_name); EditText eventName = (EditText) findViewById(R.id.event_name); EditText eventData = (EditText) findViewById(R.id.event_data); try { JSONObject data = new JSONObject(); data.put("data", eventData.getText().toString()); mPusher.send(eventName.getText().toString(), data, channelName.getText().toString()); } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:com.irccloud.android.activity.QuickReplyActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_quick_reply); if (getIntent().hasExtra("cid") && getIntent().hasExtra("bid")) { onNewIntent(getIntent());/*from w w w . j a va2 s .com*/ } else { finish(); return; } final ImageButton send = (ImageButton) findViewById(R.id.sendBtn); final EditText message = (EditText) findViewById(R.id.messageTxt); message.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) { if (actionId == EditorInfo.IME_ACTION_SEND && message.getText() != null && message.getText().length() > 0) send.performClick(); return true; } }); message.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View view, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER && message.getText() != null && message.getText().length() > 0) send.performClick(); return false; } }); send.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (message.getText() != null && message.getText().length() > 0) { Intent i = new Intent(RemoteInputService.ACTION_REPLY); i.setComponent(new ComponentName(getPackageName(), RemoteInputService.class.getName())); i.putExtras(getIntent()); i.putExtra("reply", message.getText().toString()); startService(i); finish(); } } }); ListView listView = (ListView) findViewById(R.id.conversation); listView.setAdapter(adapter); }