Domanda

In my EditText I want to enter the first character as alpha and the remaining is whatever. I achieved this task with the help of TextWatcher. But now my problem is if I entered something wrong(like digits, special characters) as my First character then my EditText shouldn't accept the remaining characters. If I correct my first character then only my EditText should accept. Is their any possibility to achieve this friends? If yes then please guide me friends.

My textWatcher code is

edittext.addTextChangedListener(new TextWatcher() {

    public void onTextChanged(CharSequence s, int start, int before, int count) {
        // TODO Auto-generated method stub

    }

    public void beforeTextChanged(CharSequence s, int start, int count,
            int after) {
        // TODO Auto-generated method stub

    }

    public void afterTextChanged(Editable s) {
        // TODO Auto-generated method stub
        if (s.length() > 0) {
            String str = edittext.getText().toString();
            char t = str.charAt(0);
            if (!Character.isLetter(t)) {
                Toast.makeText(getApplicationContext(),
                        "please enter your first charecter as alpha",
                        Toast.LENGTH_LONG).show();
            }
        }
    }
});

Thanks in advance.

È stato utile?

Soluzione

CREATE UNIQUE INDEX ON UnnamedTable (Department) WHERE Designation='Head'

It's called a Filtered Index. If you're on a pre-2008 version of SQL Server, you can implement a poor-mans equivalent of a filtered index using an indexed view:

CREATE VIEW UnnamedView
WITH SCHEMABINDING
AS
    SELECT Department From UnnamedSchema.UnnamedTable WHERE Designation='Head'
GO
CREATE UNIQUE INDEX ON UnnamedView (Department)

Altri suggerimenti

Execute the following query to view duplicates:

Select Department,Designation,count(*) 
From [mytable] Group by Department,Designation

Now replace mytable with the table name and department and designation with the columns in the table. After execution the result set will show a count of more than one for duplicate records.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top