Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8876607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:15:10+00:00 2026-06-14T19:15:10+00:00

I have implemented the code of set error on two edit text. First to

  • 0

I have implemented the code of set error on two edit text.

  • First to get any string without null or empty value.
  • Second to get any string without null or empty value and must have some Double value.

Code is as follows

import java.util.HashMap;
import java.util.Map;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class SearchPlaces extends Activity {
    EditText place;
    EditText distance;
    Button search;
    static String _place;
    static String _distance;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        place = (EditText) findViewById(R.id.place);
        distance = (EditText) findViewById(R.id.distance);
        search = (Button) findViewById(R.id.search);
        search.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Map<String, String> validate = new HashMap<String, String>();
                _place = place.getText().toString();
                _distance = distance.getText().toString();
                validate.put("placename", _place);
                validate.put("distancenumeric", _distance);
                if (!validateInputInformation(validate)) {
                    return;
                }
                if ((_place == "" && _distance == "")) {
                    Toast.makeText(getApplicationContext(),
                            "Please fill all the information",
                            Toast.LENGTH_SHORT).show();
                } else {
                    _place = place.getText().toString();
                    _distance = distance.getText().toString();
                    Intent placedist = new Intent(getApplicationContext(),
                            MainActivity.class);
                    Bundle bundle = new Bundle();

                    bundle.putString("place", _place);
                    bundle.putString("distance", _distance);

                    placedist.putExtras(bundle);
                    startActivity(placedist);
                }
            }

            private boolean validateInputInformation(
                    Map<String, String> validate) {

                String l_place = validate.get("placename");
                if (l_place == null || l_place.equals("")) {
                    place.setError("Please enter the Place First");
                    return false;
                }

                String l_distance = validate.get("distancenumeric");
                if (l_distance == null || l_distance.equals("")) {
                    distance.setError("Please enter the Distance First");
                    return false;
                }
                if (!isDoubleNumber(l_distance)) {
                    distance.setError("Please enter Numeric Value");
                    return false;
                }

                return true;

            }
            private boolean isDoubleNumber (String num) {
                try {
                    Double.parseDouble(num);
                } catch (NumberFormatException nfe) {
                    return false;
                }
                return true;
            }
        });
    }
}

after implementing that all working are going good but when I doesn’t enter and click search button the error pops up in first edit-box after that when I reenter the correct values as input needed then the error notification doesn’t disappear but search button works good.

Please help me so that the set-error notification can be removed from the first editbox.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:15:11+00:00Added an answer on June 14, 2026 at 7:15 pm

    Write below code line instead of if ((_place == "" && _distance == "")), it will solve your problem.

    if (_place.equals("") && _distance.equals(""))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented the code in Devise call backs in my application controller. First
I have implemented an error style for textboxes using the following code. This sets
I have two interfaces like these: public interface IMyInterface1 { string prop1 { get;
i have implemented code like here but it's not working for iOS 5.0, it
FOR ANYONE INTERESTED: I have implemented the code for the behaviour I am looking
I have this code implemented and I like how straight forward it is because
I have implemented the image upload code using jquery php in my php web
I have implemented correctly bump's api, and added this code: - (void) configureBump {
I have implemented one matrix multiplication with boost::numeric::ublas::matrix (see my full, working boost code
I've have already implemented pagination using the following code: public Paginacao<Anuncio> consultarPaginado(int pagina, Integer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.