List of usage examples for android.widget EditText getText
@Override
public Editable getText()
From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java
private Dialog AdminPinSetDialog(Context context) { LayoutInflater inflater = LayoutInflater.from(context); final View textEntryView = inflater.inflate(R.layout.pin_input, null); TextView pinText = (TextView) textEntryView.findViewById(R.id.pin_text); pinText.setText(R.string.admin_set_msg); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(false);//w w w. j a v a 2 s. c om builder.setTitle(R.string.admin_set_title); builder.setView(textEntryView); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { EditText pinEdite = (EditText) textEntryView.findViewById(R.id.pin_edit); String pinStr = pinEdite.getText().toString(); Utilities.Log("Pin Dialog", "pin String is " + pinStr); String data = null; try { data = Utilities.encryption("0000" + "," + "1" + "," + pinStr); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } /* check network*/ /* prepare params for server*/ HttpPost request = new HttpPost(Utilities.VALIDATE_ADDRESS); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("data", data)); // //file_name // params.add(new BasicNameValuePair("userID","0000")); // //function // params.add(new BasicNameValuePair("pre","1")); // //data // params.add(new BasicNameValuePair("password",pinStr)); /* check identity*/ try { request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); HttpResponse response = new DefaultHttpClient().execute(request); if (response.getStatusLine().getStatusCode() == 200) { String result = EntityUtils.toString(response.getEntity()); Log.d("~~~~~~~~~~http post result", result); if (result.equals("AdminIsChecked")) { //do nothing } else if (result.equals("AdminPinIsInvalid")) { imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); Toast.makeText(getApplicationContext(), R.string.input_apin_failed, Toast.LENGTH_SHORT) .show(); finish(); } else { imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); Toast.makeText(getApplicationContext(), R.string.input_apin_error, Toast.LENGTH_SHORT) .show(); finish(); } } else { Toast.makeText(getApplicationContext(), R.string.input_apin_return, Toast.LENGTH_SHORT) .show(); finish(); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); Toast.makeText(getApplicationContext(), R.string.input_apin_net_error, Toast.LENGTH_SHORT) .show(); ; finish(); } } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); finish(); } }); return builder.create(); }
From source file:com.example.castCambot.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ActionBar actionBar = getSupportActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(android.R.color.transparent)); // When the user clicks on the button, use Android voice recognition to // get text//w w w. j a va2s . c o m Button voiceButton = (Button) findViewById(R.id.voiceButton); voiceButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startVoiceRecognitionActivity(); } }); Button buttonOK = (Button) findViewById(R.id.buttonOK); buttonOK.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //startVoiceRecognitionActivity(); EditText editText1 = (EditText) findViewById(R.id.editText1); cambotIP = editText1.getText().toString(); Button buttonOK = (Button) findViewById(R.id.buttonOK); buttonOK.setVisibility(View.INVISIBLE); /* WebView mWebView = (WebView) findViewById(R.id.webView1); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setLoadWithOverviewMode(true); mWebView.getSettings().setUseWideViewPort(true); //mWebView.getSettings().setPluginState(WebSettings.PluginState.ON); mWebView.loadUrl("file:///android_asset/cambot.html"); */ } }); Button button2 = (Button) findViewById(R.id.button2); button2.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN) //System.out.println("Touch"); myHttpPost("go_forward"); else if (action == MotionEvent.ACTION_UP) //System.out.println("Release"); myHttpPost("stop"); return false; // the listener has NOT consumed the event, pass it on } }); Button button4 = (Button) findViewById(R.id.button4); button4.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN) //System.out.println("Touch"); myHttpPost("turn_left"); else if (action == MotionEvent.ACTION_UP) //System.out.println("Release"); myHttpPost("stop"); return false; // the listener has NOT consumed the event, pass it on } }); Button button6 = (Button) findViewById(R.id.button6); button6.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN) //System.out.println("Touch"); myHttpPost("turn_right"); else if (action == MotionEvent.ACTION_UP) //System.out.println("Release"); myHttpPost("stop"); return false; // the listener has NOT consumed the event, pass it on } }); Button button8 = (Button) findViewById(R.id.button8); button8.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN) //System.out.println("Touch"); myHttpPost("go_backward"); else if (action == MotionEvent.ACTION_UP) //System.out.println("Release"); myHttpPost("stop"); return false; // the listener has NOT consumed the event, pass it on } }); // Configure Cast device discovery mMediaRouter = MediaRouter.getInstance(getApplicationContext()); mMediaRouteSelector = new MediaRouteSelector.Builder().addControlCategory( CastMediaControlIntent.categoryForCast(getResources().getString(R.string.app_id))).build(); mMediaRouterCallback = new MyMediaRouterCallback(); }
From source file:com.socialapp.eventmanager.LoginActivity.java
public void login(View view) { final EditText emailView = (EditText) findViewById(R.id.email); EditText pwView = (EditText) findViewById(R.id.password); final Context currContext = this; String email = emailView.getText().toString(); String password = pwView.getText().toString(); if ((emailView.getText().toString()).matches("")) { Toast.makeText(this, "Please enter your email id", Toast.LENGTH_SHORT).show(); } else {// w w w .jav a 2s .co m Log.d(TAG, "Attempting to login with email: " + email + " password: " + password); Backend.logIn(email, password, new Backend.BackendCallback() { @Override public void onRequestCompleted(final String result) { //Log.d(TAG, "Login success. User: " + user.toString()); runOnUiThread(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), result, Toast.LENGTH_SHORT).show(); SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor editor = prefs.edit(); editor.putString("email", emailView.getText().toString()); editor.commit(); Intent intent = new Intent(currContext, MainActivity.class); startActivity(intent); } }); } @Override public void onRequestFailed(final String message) { //NOTE: parameter validation and filtering is handled by the backend, just show the //returned error message to the user Log.d(TAG, "Received error from Backend: " + message); runOnUiThread(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show(); // Delete this later on //Intent intent = new Intent(currContext, MainActivity.class); //startActivity(intent); } }); } }); } }
From source file:edu.missouri.niaaa.pain.activity.AdminManageActivity.java
private Dialog AdminPinSetDialog(final Context context) { LayoutInflater inflater = LayoutInflater.from(context); final View textEntryView = inflater.inflate(R.layout.pin_input, null); TextView pinText = (TextView) textEntryView.findViewById(R.id.pin_text); pinText.setText(R.string.admin_set_msg); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(false);//www. j a v a 2 s . c o m builder.setTitle(R.string.admin_set_title); builder.setView(textEntryView); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { EditText pinEdite = (EditText) textEntryView.findViewById(R.id.pin_edit); String pinStr = pinEdite.getText().toString(); Util.Log_debug("Pin Dialog", "pin String is " + pinStr); String data = null; try { data = Util.encryption(context, Util.ADMIN_UID + "," + "1" + "," + pinStr); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } /* check network*/ /* prepare params for server*/ HttpPost request = new HttpPost(Util.VALIDATE_ADDRESS); List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("data", data)); // //file_name // params.add(new BasicNameValuePair("userID","0000")); // //function // params.add(new BasicNameValuePair("pre","1")); // //data // params.add(new BasicNameValuePair("password",pinStr)); /* check identity*/ try { request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); HttpResponse response = new DefaultHttpClient().execute(request); if (response.getStatusLine().getStatusCode() == 200) { String result = EntityUtils.toString(response.getEntity()); Log.d("~~~~~~~~~~http post result", result); if (result.equals("AdminIsChecked")) { //do nothing } else if (result.equals("AdminPinIsInvalid")) { imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); Toast.makeText(getApplicationContext(), R.string.input_apin_failed, Toast.LENGTH_SHORT) .show(); finish(); } else { imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); Toast.makeText(getApplicationContext(), R.string.input_apin_error, Toast.LENGTH_SHORT) .show(); finish(); } } else { Toast.makeText(getApplicationContext(), R.string.input_apin_return, Toast.LENGTH_SHORT) .show(); finish(); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); Toast.makeText(getApplicationContext(), R.string.input_apin_net_error, Toast.LENGTH_SHORT) .show(); ; finish(); } } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); finish(); } }); return builder.create(); }
From source file:com.cloudant.todo.TodoActivity.java
public Dialog createNewTaskDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); View v = this.getLayoutInflater().inflate(R.layout.dialog_new_task, null); final EditText description = (EditText) v.findViewById(R.id.new_task_desc); // Check description is present, if so add a task otherwise show an error DialogInterface.OnClickListener positiveClick = new DialogInterface.OnClickListener() { @Override/* w w w . j a v a2 s. c om*/ public void onClick(DialogInterface dialog, int id) { if (description.getText().length() > 0) { createNewTask(description.getText().toString()); description.getText().clear(); } else { Toast.makeText(getApplicationContext(), R.string.task_not_created, Toast.LENGTH_LONG).show(); } } }; DialogInterface.OnClickListener negativeClick = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }; builder.setView(v).setTitle(R.string.new_task).setPositiveButton(R.string.create, positiveClick) .setNegativeButton(R.string.cancel, negativeClick); final AlertDialog d = builder.create(); // Enable "Create" button when the description has some characters final TextWatcher textWatcher = new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { final Button b = d.getButton(DialogInterface.BUTTON_POSITIVE); b.setEnabled(description.getText().length() > 0); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }; d.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { final Button b = d.getButton(DialogInterface.BUTTON_POSITIVE); b.setEnabled(description.getText().length() > 0); description.addTextChangedListener(textWatcher); } }); return d; }
From source file:com.bonsai.wallet32.SweepKeyActivity.java
public void sweepKey(View view) { if (mWalletService == null) { showErrorDialog(mRes.getString(R.string.sweep_error_nowallet)); return;/*w w w . j a v a 2 s . co m*/ } // Fetch the private key. if (mKey == null) { showErrorDialog(mRes.getString(R.string.sweep_error_nokey)); return; } // Make sure we have fetched the unspent outputs. if (mUnspentOutputs == null) { showErrorDialog(mRes.getString(R.string.sweep_error_nooutputs)); return; } // Fetch the fee amount. long fee = 0; EditText feeEditText = (EditText) findViewById(R.id.fee_btc); String feeString = feeEditText.getText().toString(); if (feeString.length() == 0) { showErrorDialog(mRes.getString(R.string.sweep_error_nofee)); return; } try { fee = mBTCFmt.parse(feeString); } catch (NumberFormatException ex) { showErrorDialog(mRes.getString(R.string.sweep_error_badfee)); return; } // Which account was selected? if (mAccountId == -1) { showErrorDialog(mRes.getString(R.string.sweep_error_noaccount)); return; } // Sweep! mWalletService.sweepKey(mKey, fee, mAccountId, mUnspentOutputs); // Head to the transaction view for this account ... Intent intent = new Intent(this, ViewTransactionsActivity.class); Bundle bundle = new Bundle(); bundle.putInt("accountId", mAccountId); intent.putExtras(bundle); startActivity(intent); // We're done here ... finish(); }
From source file:net.kourlas.voipms_sms.activities.ConversationActivity.java
public void preSendMessage() { EditText messageEditText = (EditText) findViewById(R.id.message_edit_text); String messageText = messageEditText.getText().toString(); while (true) { if (messageText.length() > 160) { long databaseId = database .insertMessage(new Message(preferences.getDid(), contact, messageText.substring(0, 160))); messageText = messageText.substring(160); adapter.refresh();/*from ww w . j a v a 2s . co m*/ preSendMessage(databaseId); } else { long databaseId = database.insertMessage( new Message(preferences.getDid(), contact, messageText.substring(0, messageText.length()))); adapter.refresh(); preSendMessage(databaseId); break; } } messageEditText.setText(""); }
From source file:sundroid.code.SundroidActivity.java
/** Called when the activity is first created. ***/ @Override// w ww .java 2s. c o m public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); this.chk_usecelsius = (CheckBox) findViewById(R.id.chk_usecelsius); Button cmd_submit = (Button) findViewById(R.id.cmd_submit); cmd_submit.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { try { ///////////////// Code to get weather conditions for entered place /////////////////////////////////////////////////// String cityParamString = ((EditText) findViewById(R.id.edit_input)).getText().toString(); String queryString = "https://www.google.com/ig/api?weather=" + cityParamString; queryString = queryString.replace("#", ""); /* Parsing the xml file*/ SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); GoogleWeatherHandler gwh = new GoogleWeatherHandler(); xr.setContentHandler(gwh); HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(queryString.replace(" ", "%20")); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(httpget, responseHandler); ByteArrayInputStream is = new ByteArrayInputStream(responseBody.getBytes()); xr.parse(new InputSource(is)); Log.d("Sundroid", "parse complete"); WeatherSet ws = gwh.getWeatherSet(); newupdateWeatherInfoView(R.id.weather_today, ws.getWeatherCurrentCondition(), " " + cityParamString, ""); ///////////////// Code to get weather conditions for entered place ends /////////////////////////////////////////////////// ///////////////// Code to get latitude and longitude using zipcode starts /////////////////////////////////////////////////// String latlng_querystring = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + cityParamString.replace(" ", "%20") + "&sensor=false"; URL url_latlng = new URL(latlng_querystring); spf = SAXParserFactory.newInstance(); sp = spf.newSAXParser(); xr = sp.getXMLReader(); xmlhandler_latlong xll = new xmlhandler_latlong(); xr.setContentHandler(xll); xr.parse(new InputSource(url_latlng.openStream())); Latitude_longitude ll = xll.getLatlng_resultset(); double selectedLat = ll.getLat_lng_pair().getLat(); double selectedLng = ll.getLat_lng_pair().getLon(); ///////////////// Code to get latitude and longitude using zipcode ends /////////////////////////////////////////////////// ///////////////// Code to get miles from text box & convert to meters for passing into the api link//////////////////////// EditText edt = (EditText) findViewById(R.id.edit_miles); float miles = Float.valueOf(edt.getText().toString()); float meters = (float) (miles * 1609.344); ///////////////// Code to get miles from text box & convert to meters for passing into the api link ends ///////////////// ///////////////// Code to pass lat,long and radius and get destinations from places api starts////////// ///////////////// URL queryString_1 = new URL("https://maps.googleapis.com/maps/api/place/search/xml?location=" + Double.toString(selectedLat) + "," + Double.toString(selectedLng) + "&radius=" + Float.toString(meters) + "&types=park|types=aquarium|types=point_of_interest|types=establishment|types=museum&sensor=false&key=AIzaSyDmP0SB1SDMkAJ1ebxowsOjpAyeyiwHKQU"); spf = SAXParserFactory.newInstance(); sp = spf.newSAXParser(); xr = sp.getXMLReader(); xmlhandler_places xhp = new xmlhandler_places(); xr.setContentHandler(xhp); xr.parse(new InputSource(queryString_1.openStream())); int arraysize = xhp.getVicinity_List().size(); String[] place = new String[25]; String[] place_name = new String[25]; Double[] lat_pt = new Double[25]; Double[] lng_pt = new Double[25]; int i; //Getting name and vicinity tags from the xml file// for (i = 0; i < arraysize; i++) { place[i] = xhp.getVicinity_List().get(i); place_name[i] = xhp.getPlacename_List().get(i); lat_pt[i] = xhp.getLatlist().get(i); lng_pt[i] = xhp.getLonglist().get(i); System.out.println("long -" + lng_pt[i]); place[i] = place[i].replace("#", ""); } ///////////////// Code to pass lat,long and radius and get destinations from places api ends////////// ///////////////// //////////////////////while loop for getting top 5 from the array//////////////////////////////////////////////// int count = 0; int while_ctr = 0; String str_weathercondition; str_weathercondition = ""; WeatherCurrentCondition reftemp; //Places to visit if none of places in the given radius are sunny/clear/partly cloudy String[] rainy_place = { "Indoor Mall", "Watch a Movie", "Go to a Restaurant", "Shopping!" }; double theDistance = 0; String str_dist = ""; while (count < 5) { //Checking if xml vicinity value is empty while (place[while_ctr] == null || place[while_ctr].length() < 2) { while_ctr = while_ctr + 1; } //First search for places that are sunny or clear if (while_ctr < i - 1) { queryString = "https://www.google.com/ig/api?weather=" + place[while_ctr]; System.out.println("In while loop - " + queryString); theDistance = (Math.sin(Math.toRadians(selectedLat)) * Math.sin(Math.toRadians(lat_pt[while_ctr])) + Math.cos(Math.toRadians(selectedLat)) * Math.cos(Math.toRadians(lat_pt[while_ctr])) * Math.cos(Math.toRadians(selectedLng - lng_pt[while_ctr]))); str_dist = new Double((Math.toDegrees(Math.acos(theDistance))) * 69.09).intValue() + " miles"; System.out.println(str_dist); spf = SAXParserFactory.newInstance(); sp = spf.newSAXParser(); xr = sp.getXMLReader(); gwh = new GoogleWeatherHandler(); xr.setContentHandler(gwh); httpclient = new DefaultHttpClient(); httpget = new HttpGet(queryString.replace(" ", "%20")); responseHandler = new BasicResponseHandler(); responseBody = httpclient.execute(httpget, responseHandler); is = new ByteArrayInputStream(responseBody.getBytes()); xr.parse(new InputSource(is)); if (gwh.isIn_error_information()) { System.out.println("Error Info flag set"); } else { ws = gwh.getWeatherSet(); reftemp = ws.getWeatherCurrentCondition(); str_weathercondition = reftemp.getCondition(); // Check if the condition is sunny or partly cloudy if (str_weathercondition.equals("Sunny") || str_weathercondition.equals("Mostly Sunny") || str_weathercondition.equals("Clear")) { System.out.println("Sunny Loop"); // Increment the count ++count; // Disply the place on the widget if (count == 1) { newupdateWeatherInfoView(R.id.weather_1, reftemp, place_name[while_ctr], str_dist); } else if (count == 2) { newupdateWeatherInfoView(R.id.weather_2, reftemp, place_name[while_ctr], str_dist); } else if (count == 3) { newupdateWeatherInfoView(R.id.weather_3, reftemp, place_name[while_ctr], str_dist); } else if (count == 4) { newupdateWeatherInfoView(R.id.weather_4, reftemp, place_name[while_ctr], str_dist); } else if (count == 5) { newupdateWeatherInfoView(R.id.weather_5, reftemp, place_name[while_ctr], str_dist); } else { } } } } // If Five sunny places not found then search for partly cloudy places else if (while_ctr >= i && while_ctr < i * 2) { queryString = "https://www.google.com/ig/api?weather=" + place[while_ctr - i]; queryString = queryString.replace(" ", " "); spf = SAXParserFactory.newInstance(); sp = spf.newSAXParser(); // Get the XMLReader of the SAXParser we created. xr = sp.getXMLReader(); gwh = new GoogleWeatherHandler(); xr.setContentHandler(gwh); // Use HTTPClient to deal with the URL httpclient = new DefaultHttpClient(); httpget = new HttpGet(queryString.replace(" ", "%20")); responseHandler = new BasicResponseHandler(); responseBody = httpclient.execute(httpget, responseHandler); is = new ByteArrayInputStream(responseBody.getBytes()); xr.parse(new InputSource(is)); Log.d(DEBUG_TAG, "parse complete"); if (gwh.isIn_error_information()) { } else { ws = gwh.getWeatherSet(); reftemp = ws.getWeatherCurrentCondition(); str_weathercondition = reftemp.getCondition(); // Check if the condition is sunny or partly cloudy if (str_weathercondition.equals("Partly Cloudy")) { count = count + 1; // Display the place if (count == 1) { newupdateWeatherInfoView(R.id.weather_1, reftemp, place_name[while_ctr - i], str_dist); } else if (count == 2) { newupdateWeatherInfoView(R.id.weather_2, reftemp, place_name[while_ctr - i], str_dist); } else if (count == 3) { newupdateWeatherInfoView(R.id.weather_3, reftemp, place_name[while_ctr - i], str_dist); } else if (count == 4) { newupdateWeatherInfoView(R.id.weather_4, reftemp, place_name[while_ctr - i], str_dist); } else if (count == 5) { newupdateWeatherInfoView(R.id.weather_5, reftemp, place_name[while_ctr - i], str_dist); } else { } } } } //////////////////////////////// Give suggestions for a rainy day else { queryString = "https://www.google.com/ig/api?weather=" + cityParamString; queryString = queryString.replace("#", ""); spf = SAXParserFactory.newInstance(); sp = spf.newSAXParser(); // Get the XMLReader of the SAXParser we created. xr = sp.getXMLReader(); gwh = new GoogleWeatherHandler(); xr.setContentHandler(gwh); httpclient = new DefaultHttpClient(); httpget = new HttpGet(queryString.replace(" ", "%20")); // create a response handler responseHandler = new BasicResponseHandler(); responseBody = httpclient.execute(httpget, responseHandler); is = new ByteArrayInputStream(responseBody.getBytes()); xr.parse(new InputSource(is)); if (gwh.isIn_error_information()) { } else { ws = gwh.getWeatherSet(); reftemp = ws.getWeatherCurrentCondition(); str_weathercondition = reftemp.getCondition(); if (count == 0) { newupdateWeatherInfoView(R.id.weather_1, reftemp, rainy_place[0], ""); newupdateWeatherInfoView(R.id.weather_2, reftemp, rainy_place[1], ""); newupdateWeatherInfoView(R.id.weather_3, reftemp, rainy_place[2], ""); newupdateWeatherInfoView(R.id.weather_4, reftemp, rainy_place[3], ""); newupdateWeatherInfoView(R.id.weather_5, reftemp, rainy_place[1], ""); } else if (count == 1) { newupdateWeatherInfoView(R.id.weather_2, reftemp, rainy_place[1], ""); newupdateWeatherInfoView(R.id.weather_3, reftemp, rainy_place[2], ""); newupdateWeatherInfoView(R.id.weather_4, reftemp, rainy_place[3], ""); newupdateWeatherInfoView(R.id.weather_5, reftemp, rainy_place[0], ""); } else if (count == 2) { newupdateWeatherInfoView(R.id.weather_3, reftemp, rainy_place[2], ""); newupdateWeatherInfoView(R.id.weather_4, reftemp, rainy_place[0], ""); newupdateWeatherInfoView(R.id.weather_5, reftemp, rainy_place[1], ""); } else if (count == 3) { newupdateWeatherInfoView(R.id.weather_4, reftemp, rainy_place[0], ""); newupdateWeatherInfoView(R.id.weather_5, reftemp, rainy_place[1], ""); } else if (count == 4) { newupdateWeatherInfoView(R.id.weather_5, reftemp, rainy_place[1], ""); } else { } count = 5; } count = 5; } while_ctr++; } /////////////Closing the soft keypad//////////////// InputMethodManager iMethodMgr = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); iMethodMgr.hideSoftInputFromWindow(edt.getWindowToken(), 0); } catch (Exception e) { resetWeatherInfoViews(); Log.e(DEBUG_TAG, "WeatherQueryError", e); } } }); }
From source file:de.gadc.moneybeam.MoneyBeamActivity.java
/** * This method presents the user the dialog that enables him to enter his * email address.//w ww. java 2s. c o m */ private void showEmailDialog() { final EditText editText = new EditText(this); AlertDialog.Builder emailDialogBuilder = new Builder(this); emailDialogBuilder.setTitle(R.string.hint_email); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); editText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); emailDialogBuilder.setView(editText); emailDialogBuilder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String mail = editText.getText().toString(); prefs.edit().putString(Configuration.PREF_MAIL, mail).commit(); } }); emailDialogBuilder.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); emailDialogBuilder.show(); }