BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-09-2007, 10:21 AM   #1
rock_win
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
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
arifzaman
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
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
Skipper_Joe
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
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
arifzaman
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
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
Skipper_Joe
Talking BlackBerry Encyclopedia
 
Skipper_Joe's Avatar
 
Join Date: Jan 2007
Location: Kharkov, Ukraine
Model: 8300
Carrier: N/A
Posts: 237
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
arifzaman
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Default

Thanks Skipper_Joe!

It's now working for me.

Thanks,
ARIF
Offline  
Old 08-20-2007, 08:43 AM   #7
rock_win
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


RADSTONE VME BOARD PME 68-33 MOTOROLA 6800 33Mhz AMIGA PPC picture

RADSTONE VME BOARD PME 68-33 MOTOROLA 6800 33Mhz AMIGA PPC

$185.00



New Amiga Gotek OLED IIC I2C 0.91

New Amiga Gotek OLED IIC I2C 0.91" 128x32 LCD Display Module 3.3V 5V White #679

$7.25



Commodore Amiga 500 500+ 570 600 1200 2000 3000 4000 CD32 PSU Capacitor Kit picture

Commodore Amiga 500 500+ 570 600 1200 2000 3000 4000 CD32 PSU Capacitor Kit

$20.00



New Greaseweazle V4 USB Floppy Adapter Flux Reader Writer Amiga PC Amstrad #1059 picture

New Greaseweazle V4 USB Floppy Adapter Flux Reader Writer Amiga PC Amstrad #1059

$27.70



New 1989 Commodore Amiga 315093-02 ROM Chip IC 5 pcs. picture

New 1989 Commodore Amiga 315093-02 ROM Chip IC 5 pcs.

$50.00



NEW OPTICAL LASER PICKUP HEAD for AMIGA CD 32 SYSTEM CONSOLE picture

NEW OPTICAL LASER PICKUP HEAD for AMIGA CD 32 SYSTEM CONSOLE

$26.93







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