Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
patilajayr
Posts: 385
Registered: 07-28-2010
My Carrier: hi

field with scrollable

hello friends,

       here is code for dialog alert. my problem is that i am passing the value to this class in multiple line. it should be 255 char.  for that i am using lable field. i want to show that 3 line alert and if the text is more than 3 line that it should be scrollable. please help me for that. i am put the value to lable filed is mname...........

package com.txla.ui;


import com.txla.controller.Controller;
import com.txla.controller.ModelController;
import com.txla.datastore.DataStoreManager;
import com.txla.main.Main;
import com.txla.model.UserInfo;
import com.txla.util.Constants;
import com.txla.util.Utility;

import net.rim.device.api.system.Characters;
import net.rim.device.api.system.DeviceInfo;
import net.rim.device.api.system.KeyListener;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Screen;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.AutoTextEditField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.component.Status;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.PopupScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class PushNotificationMessage extends PopupScreen implements FieldChangeListener {

   

    private ButtonField btnSubmit;
    private ButtonField btnCancel;

    HorizontalFieldManager hfm;
    public static String emailId;
    public static String PIN;
    private LabelField lblTitle1;
   public String download_path;//="http://173.255.193.143/api/uploads_dev/FedSearchNSeizure.zip";
	
    
    public PushNotificationMessage(String mname, String downloadlink) {
        super(new VerticalFieldManager(), Field.FOCUSABLE);
        
        lblTitle1 = new LabelField("PushLegal Notification",
                LabelField.FIELD_HCENTER);
        lblTitle1.setFont(lblTitle1.getFont().derive(Font.PLAIN, 10,
                Ui.UNITS_pt));
        PIN = (Integer.toString(DeviceInfo.getDeviceId(),16)).toUpperCase();
        download_path=downloadlink;
        add(lblTitle1);
        add(new SeparatorField());
        LabelField question = new LabelField(""+
mname
,LabelField.FOCUSABLE);
        question.setMargin(20, 0, 5, 0);//question.setMargin(20, 0, 0, 0)
        
        
        btnSubmit = new ButtonField("Download", ButtonField.CONSUME_CLICK);
        btnCancel = new ButtonField("Cancel", ButtonField.CONSUME_CLICK);
        btnSubmit.setChangeListener(this);
        btnCancel.setChangeListener(this);

        hfm = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);
        hfm.add(btnSubmit);
        hfm.add(new LabelField("  "));
        hfm.add(btnCancel);
        add(question);
        add(new SeparatorField());
        add(hfm);

        PushNotificationMessageListener listener = new PushNotificationMessageListener(this);
        this.addKeyListener(listener);
    }

 	public void show() {
        UiApplication.getUiApplication().pushModalScreen(this);
    }
   

    public void fieldChanged(Field field, int context) {
        UiApplication ui = UiApplication.getUiApplication();
        Screen s = ui.getActiveScreen();
      
        if(field.equals(btnSubmit)) 
        {
            if ( download_path.length()!= 0) 
            {
            	if (DataStoreManager.checkSDCard()) {
    				String fileLocation = Utility.getDBLocation( download_path);
    							startDownload();
    			s.close();
    			
    		}
              
            }
        }
        else if (field.equals(btnCancel)) {
          
            s.close();
            //System.exit(0);
        }

    }
    public void startDownload() {
 		Constants.URL_DOWNLOAD_BOOK = download_path;
        System.out.println("Notification download link"+download_path);
 		String zipFileLocation = Utility.getZipFileLocation() + ".zip";
  		System.out.println(zipFileLocation);
 		Controller.getInstance().downloadBook( download_path,zipFileLocation ,"Downloading book. Please wait!!",true);
	}
   
    private class PushNotificationMessageListener implements KeyListener {

        private PushNotificationMessage screen;

        public PushNotificationMessageListener(PushNotificationMessage screen) {
            this.screen = screen;
        }

        public boolean keyChar(char key, int status, int time) {
            // intercept the ESC key - exit the splash screen
            boolean retval = false;

            switch (key) {
                case Characters.ESCAPE:
                  
                    screen.close();
                    retval = true;
                    break;
            }

            return retval;
        }

        /** Implementation of KeyListener.keyDown */
        public boolean keyDown(int keycode, int time) {
            return false;
        }

        /** Implementation of KeyListener.keyRepeat */
        public boolean keyRepeat(int keycode, int time) {
            return false;
        }

        /** Implementation of KeyListener.keyStatus */
        public boolean keyStatus(int keycode, int time) {
            return false;
        }

        /** Implementation of KeyListener.keyUp */
        public boolean keyUp(int keycode, int time) {
            return false;
        }
    }

}

 test1.jpg

 

that is come my output. my problem is that i am suing lable field. how yould i give area to that field? and scroll. please help me for that.

 

thanks and reagards,

  ajay patil.

Please use plain text.
Developer
simon_hain
Posts: 10,780
Registered: 07-29-2008
My Carrier: O2 Germany

Re: field with scrollable

use a verticalfieldmanager with scrollable style and set its available height to the value you want (using a custom layout).
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

peter_strange wrote:
"This process should happen traumatically for you in both JDE and Eclipse."
Please use plain text.
Developer
patilajayr
Posts: 385
Registered: 07-28-2010
My Carrier: hi

Re: field with scrollable

thanks for rpl. means suppose i create one vertical field. which scrollable. how should i specifed to the area of that lable field menas. i want 3 line lable field. if text come more than 3 line our text should be scrollable.. how should i do that ? please help me.

 

i am use

VerticalFieldManager  mainvfm=new VerticalFieldManager(Manager.VERTICAL_SCROLL|Manager.VERTICAL_SCROLLBAR);

 

how should i do that? lable and scroll? how hould i give specific area to that field.

 

thanks and regards

ajay patil.

Please use plain text.
Developer
simon_hain
Posts: 10,780
Registered: 07-29-2008
My Carrier: O2 Germany

Re: field with scrollable

getPreferredHeight, for example
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

peter_strange wrote:
"This process should happen traumatically for you in both JDE and Eclipse."
Please use plain text.
Contributor
BrajeshSanodiya
Posts: 10
Registered: 08-03-2011
My Carrier: BlackBerry Developer

Re: field with scrollable

add ur "question" LabelField to first in VerticalFieldManager which is Vertical Scrollable then add this manager to HorizontalFieldManager which is Not Vertical Scrollable. like this.

HorizontalFieldManager hfmLabel=new HorizontalFieldManager(NO_VERTICAL_SCROLL);
VerticalFieldManager vfmLabel=new VerticalFieldManager(VERTICAL_SCROLL);
vfmLabel.add(question);
hfmLabel.add(vfmLabel);
add(hfmLabel);

try this.
Please use plain text.
Developer
arkadyz
Posts: 2,146
Registered: 07-08-2009
My Carrier: various

Re: field with scrollable


patilajayr wrote:

 

how should i do that? lable and scroll? how hould i give specific area to that field.

 

thanks and regards

ajay patil.


This is a question that has been answered many times over on these forums. Override this VerticalFieldManager's sublayout with something like this:

protected void sublayout(int maxWidth, int maxHeight) {
  super.sublayout(maxWidth, Math.min(maxHeight, myDesiredHeight));
}

 where myDesiredHeight is the value you calculate separately. For your purposes, font height multiplied by 3 seems to be a good choice.

 

However, you will have to let the user scroll the text. LabelField is not well suited for this purpose. I suggest a TextField that is FOCUSABLE and READONLY to allow user navigation through the text. Alternatively you can capture navigationMovement in your buttons and scroll the manager programmatically (using setVerticalScroll) in case of vertical movements.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.