BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-08-2007, 11:14 AM   #1 (permalink)
New Member
 
Join Date: Oct 2007
Model: 7100T
PIN: N/A
Carrier: Tmobile
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy help on writing a local Lookup app?

Please Login to Remove!

Hi
I am trying to write an app which does a simple look-up a local list as the user types in a search string.

As the user types the search string, the matching entries are displayed in a list below.
Can anyone guide me in the right direction?

Thanks.
Offline  
Old 10-08-2007, 11:33 AM   #2 (permalink)
New Member
 
Join Date: Oct 2007
Model: 7100T
PIN: N/A
Carrier: Tmobile
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

bump
Offline  
Old 10-08-2007, 08:57 PM   #3 (permalink)
New Member
 
Join Date: Feb 2007
Model: 8800
Carrier: Cingular
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default ECL Sample Application

The ECL Application on the Blackberry Java samples page is a nice example of creating a "Find" field at the top of the Blackberry device screen and allowing a type ahead to locate the indexed record. Here is some of the code:

EditFind.java
package com.rim.samples.MultipleScreen.src;

import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.EditField;

/**
* <description> Creates the Find Field that is part of the DisplayScreen
*/
public class FindEditField extends EditField {
/**
* <description> Adds a label and creates an empty Edit Field.
*/
public FindEditField() {
super("Find: ","");
}

}
FindContact.Java
package com.rim.samples.MultipleScreen.src;
import java.util.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
/**
* <description> Parses through the a given list field of all contacts to find the index of a selected contact
*/

class FindContact {
/**
* <description> empty constructor
*/
FindContact() { }
/**
* <description>Gets the index of a selected contact from the full list
* @param contacts <description> The selected contact
* @param AllContacts <description> List of all contacts
* @return <description> The index location of the selected contact
*/
public int getContact(ObjectListField contacts, ObjectListField AllContacts){
//get the selected contact
int i =contacts.getSelectedIndex();
String name=(String)contacts.get(contacts,i);
//we need to parse through the list to get the vector location of the selected contact
//only useable if someone is using the find field function on the DisplayScreen
int count;
int size=AllContacts.getSize();
for(count=0;count<size;count++){
String temp=(String)AllContacts.get(AllContacts,count);
//the names are being matched to get the vector location
if(name.equals(temp))break;
}
return count;

}

}
__________________
Kurt Sanders, Illinois
Blackberry 8800
Offline  
Old 10-09-2007, 09:15 AM   #4 (permalink)
New Member
 
Join Date: Oct 2007
Model: 7100T
PIN: N/A
Carrier: Tmobile
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Kurt,

I tried looking around for the sample, but could not locate it.
Livelink - Redirection

Am i looking at the right place?
Livelink - Redirection


Thanks
Offline  
Old 10-09-2007, 10:06 AM   #5 (permalink)
New Member
 
Join Date: Oct 2007
Model: 7100T
PIN: N/A
Carrier: Tmobile
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have created an application using the ObjectChoiceField, but here are the issues:

I need to be able to type in the dropdown box and as i type, the list should get narrower matching the typed letters.

Also, I have about 200-230 items that need to be in the list. Is there a way that i don't have to hardcode everyting? I mean if ican store the data in an xml file on the device, it would be great.

I am a c++ developer and dont have much experience in java. Any help would be appreciated. Here is the code so far:


import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.blackberry.api.homescreen.*;
import java.util.Date;
import net.rim.device.api.i18n.SimpleDateFormat;

/*
* BlackBerry applications that provide a user interface must extend UiApplication.
*/

class OnCall extends net.rim.device.api.ui.UiApplication
{

public static void main(String[] args){

//create a new instance of the application, then start the application on the event thread
OnCall theApp = new OnCall();
theApp.enterEventDispatcher();

}
public OnCall(){

//display a new screen
pushScreen(new OnCallScreen());
}

}

//create a new screen that extends MainScreen, which provides default standard behavior for BlackBerry applications
final class OnCallScreen extends MainScreen{

public ObjectChoiceField partNumberDropDown = new ObjectChoiceField();
public FieldListener partNumberDropDownListener = new FieldListener();
public int holding;
public Font boldFont;
public RichTextField appHeader = new RichTextField(" List");
public LabelField priceLabel;
public OnCallScreen(){

//invoke the MainScreen constructor
super();

boldFont = Font.getDefault().derive(Font.BOLD);

//add a title to the screen
LabelField title = new LabelField("List", LabelField.ELLIPSIS
| LabelField.USE_ALL_WIDTH);
setTitle(title);
//add text to the screen
//add(appHeader);
//appHeader.setFont(boldFont);
add(new SeparatorField());
String choices[] = {"P234K3000000","A234K3000000", "PF34K3000000", "VA34K3000000", "DSC4K3000000", "SDE4K3000000", "KZ34K3000000", "PQ34K3000000", "SA34K3000000", "DXC4K3000000", "SA34K3000000", "KK34K3000000"};
//partNumberDropDown = new ObjectChoiceField("Select Date:", choices);
partNumberDropDown.setLabel("Select Part Number");
partNumberDropDown.setChoices(choices);
add(partNumberDropDown);
partNumberDropDown.setFocus();
partNumberDropDown.setChangeListener(partNumberDro pDownListener);

}

private static class FieldListener implements FieldChangeListenern
{
public void fieldChanged(Field partNumberDropDown, int context)
{
//If the ObjectCoiceField has changed
if (partNumberDropDown instanceof ObjectChoiceField)
{
ObjectChoiceField choiceField = (ObjectChoiceField) partNumberDropDown;
Dialog.alert(choiceField.getSelectedIndex() + "");
}
}
}

//override the onClose() method to display a dialog box to the user with "Goodbye!" when closed
public boolean onClose()
{
Dialog.alert("Goodbye!");
System.exit(0);
return true;
}
}
Offline  
Old 10-09-2007, 03:23 PM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2005
Model: 8830
Carrier: Verizon
Posts: 144
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

aw44,

I'm not sure I understand what you are trying to do. Do you want a field that has a list of values AND that the user can enter a new value that doesn't appear in the list?

As far as storing the data on the BB, look into using the Persistent Store. There are several sample apps when you installed the JDE that can get you started.

fbrimm
Offline  
Old 10-09-2007, 03:45 PM   #7 (permalink)
New Member
 
Join Date: Oct 2007
Model: 7100T
PIN: N/A
Carrier: Tmobile
Posts: 5
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

fbrimm,

The objective of the app is that user enters a partnumber and then some relavent info about the part is displayed. All this has to be stored on the device.

Ideally, as user is typing in the part number, the drop down list matching the number should get narrower .. I hope i am able to explain this a bit..

I just tried to implement it using a dropdown box, which is not a good solution.

Any other idea would be really appreciated.
Offline  
Old 10-10-2007, 03:14 PM   #8 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2005
Model: 8830
Carrier: Verizon
Posts: 144
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I haven't played with the ECL code yet, but it looks like it should do what you are looking for.

I've done something similar combing a EditField and an ObjectChoiceField. As the user starts typing in the EditField, the choices in the ObjectChoiceField are changed to reflect what matches. I had to do this to allow the user the ability to enter something if it didn't existing in the ObjectChoiceField list of choices.

The ObjectChoiceField by default will search for a match based on the character the user presses, but the problem is it only searches the first character in the list of values. The ECL code looks like it should allow the search to continue as more characters are typed.

fbrimm
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





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