BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-09-2007, 10:21 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question How to make a custom Filter?

Please Login to Remove!

Hi

I have made a custom edit filed, and i want to have a filter of alpha numeric characters for it.

i do have an Integer -- for numeric

and for alphabets:: lower case and upper case filter.

How can i set all 3 for one filed, or make a custom filter like wise.

Please help me, Thanks!
Offline  
Old 08-12-2007, 06:02 AM   #2 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi all,

I'm also facing the same problem. I've tried with different ways but No Luck!

Case 1:
Code:
BasicEditField field = new BasicEditField("Input: ", "", 100, 
       BasicEditField.FILTER_UPPERCASE | BasicEditField.FILTER_LOWERCASE | BasicEditField.FILTER_INTEGER);
Case 2:
Code:
BasicEditField field = new BasicEditField("Input: ", "");        
field.setFilter(TextFilter.get(TextFilter.UPPERCASE | TextFilter.LOWERCASE | TextFilter.INTEGER));
Actually, no difference between two cases.

Is it possible by setting only STYLE property or have to write a custom EditField component?

Help me with your valuable feedback!

Thanks,
ARIF

Last edited by arifzaman : 08-12-2007 at 06:08 AM.
Offline  
Old 08-20-2007, 12:30 AM   #3 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

frankly speaking, I'm not sure what result you are trying to achieve, but we played TextFilter interface and it worked.
We define custom implementation of TextFilter and use method BasicEditField.setFilter() to define our custom implementation for edit field.
Offline  
Old 08-20-2007, 01:01 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Skipper_Joe View Post
frankly speaking, I'm not sure what result you are trying to achieve, but we played TextFilter interface and it worked.
We define custom implementation of TextFilter and use method BasicEditField.setFilter() to define our custom implementation for edit field.
Thanks Skipper_Joe!

I want to design a custom EditField which will accept only Integer text, Uppercase, and Lowercase alpha characters for input.

A Code snippet would help.

Thanks,
ARIF
Offline  
Old 08-20-2007, 01:26 AM   #5 (permalink)
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is the sample:

Code:
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.text.TextFilter;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.container.MainScreen;

public class TFilterApp extends UiApplication
{
    private static class Form extends MainScreen
    {
        public Form()
        {
            setTitle("Test app");
            BasicEditField field = new BasicEditField("Enter data:", "");
            field.setFilter(new TextFilter()
            {

                public char convert(char c, int i)
                {
                    return c;  // don't convert anything here
                }

                public boolean validate(char c)
                {
                    return (Character.isDigit(c) || Character.isLowerCase(c) || Character.isUpperCase(c));
                }
            });
            add(field);
        }
    }


    TFilterApp()
    {
        pushScreen(new Form());
    }

    public static void main(String[] args)
    {
        TFilterApp app = new TFilterApp();
        app.enterEventDispatcher();
    }
}
Offline  
Old 08-20-2007, 03:54 AM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Skipper_Joe!

It's now working for me.

Thanks,
ARIF
Offline  
Old 08-20-2007, 08:43 AM   #7 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks Skipper
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

OEM Genuine IBM POS Display with POLE PN - 41K6814
$24.99
OEM Genuine IBM POS Display with POLE PN - 41K6814 pictureIBM #4 Y Cable Genuine OEM Long POS Cash Register 4A to 4B 10N1002 J96367
$24.99
IBM #4 Y Cable Genuine OEM Long POS Cash Register 4A to 4B 10N1002 J96367 pictureLOT of 12 GENUINE OEM IBM EASYSTRIKE LIFT OFF TAPE CASSETTES #1337765
$40.0
LOT of 12 GENUINE OEM IBM EASYSTRIKE LIFT OFF TAPE CASSETTES #1337765  pictureEE8: Genuine OEM IBM 16V 4.5A Laptop AC Power Adapter 02K6749 02K6756
$12.79
EE8: Genuine OEM IBM 16V 4.5A Laptop AC Power Adapter 02K6749 02K6756  picture3 NEW Genuine OEM IBM Lexmark 1361190 Correctable Typewriter Ribbon NOS
$9.98
3 NEW Genuine OEM IBM Lexmark 1361190 Correctable Typewriter Ribbon NOS picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.