02-09-2012 05:25 AM
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.HorizontalFieldManmnameager; import net.rim.device.api.ui.container.PopupScreen; import net.rim.device.api.ui.container.VerticalFieldManag er; 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/FedSearchNS eizure.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)).to UpperCase(); download_path=downloadlink; add(lblTitle1); add(new SeparatorField()); LabelField question = new LabelField(""+
,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.FIEL D_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(t his);
}
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(PushNotificationMe ssage 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;
}
}
}
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.
02-09-2012 05:40 AM
02-09-2012 06:10 AM
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|Manag
how should i do that? lable and scroll? how hould i give specific area to that field.
thanks and regards
ajay patil.
02-09-2012 06:59 AM
02-09-2012 07:17 AM
02-09-2012 09:40 AM
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.