How to create a LWUIT List screen in j2me? - java-me

i want to create a lwuit list screeen ,the list items are coming to my method from Rss Feed in a loop continuosly,but i am able to append 1 title from rss feed and able to display on device,after that 2,3,4,etcc...items are changing ,but finally,i am able to display 1 title and last title only,here is my code:
//method called by the parsing thread
public void addNews(News newsItem,Vector news) {
String newsArray[]={newsItem.getTitle()};
myNewsList = new List(newsArray);
System.out.println(newsItem.getTitle());//Here i am able to display,second title after that,it is not appending adding to myNewsList
//myNewsList.addItem(newsItem.getTitle());
form1.addComponent(myNewsList);
form1.show();
}
Can you help?

You need to read up about using Lists and the model in LWUIT. When using addItem you should invoke it from the EDT using LWUIT's callSerially method.
Regardless, calling addItem one by one is VERY slow. You should use a model to represent your data, see the makeover demo.

Related

Building a simple to-do list app with SwiftUI - date formatting

I’m playing about with SwiftUI for the first time with a simple to do style app. It has 2 views, one a list view, and the other an Add To Do view, which saves info into core data. In core data I have an entity called ToDo with 2 attributes - title (String) and completion (Date).
In the list view I would like to show the entry - the title and completion date on the same line. I thought I would use string interpolation to do this but run into this error:
Cannot convert value of type 'String' to expected argument type 'Date’.
The code I am using is this:
Text ("\(listedToDo.title!) needs completing by \(listedToDo.completion!)”)
I’ve not really worked with DatePickers and DateFormatters before but it may be how I’m saving the date into core data on the Add Item View?
On that file I added the following variable to your code:
#state var toDoCompletion = Date()
I added this DatePicker to the view:
DatePicker(“Completion date:", selection: $toDoCompletion, displayedComponents: .date)
And the save code:
let newToDoCompletion = ToDo(context: viewContext)
newToDoCompletion.completion = toDoCompletion
How can I finish this last bit on the list view?

Trying to customize JAMS LaborEntry screen, looking for the line of code that will update the header

Brand new to Acumatica development and stuck on a simple thing. :(
I am customizing the LaborEntry screen of the JAMS MFG.
I have added a field to the header by extending the AMBatch DAC, called UsrTimeClocked.
For now I simply wish to set this field to a number right at the end of the RowInserted event at the detail level of the AMMTran and see my number on the screen, up on the header AMBatch.
public class LaborEntry_Extension : PXGraphExtension<LaborEntry>
{
protected virtual void _(Events.RowInserted<AMMTran> e)
{
AMBatchExt ext = Base.batch.Current.GetExtension<AMBatchExt>();
ext.UsrTimeClocked = 5.32;
//Insert line to update the correct object to see 5.32 in the TextBox, before RowSelected is done.
}
}
As is my value goes in the field and any refresh/save/delete of the row does update the correct object and I see my value where I want it. I wish to know the way to force this update.

TestFx - How to test validation dialogs with no ids

I have an application with grid of records and button insert. After clicking insert, there is a form, where you fill in data and click Ok for adding new record to the grid. After clicking Ok, there is validation which fires dialog with error informations, if any of the text fields do not match validation rules. Is there any posible way to test text on the dialog with textFx, if the dialog has no id?
This is an example for Alert based dialog:
In your test:
alert_dialog_has_header_and_content(
"Removing 'Almaty' location", "Are you sure to remove this record?");
In you helper test class:
public void alert_dialog_has_header_and_content(final String expectedHeader, final String expectedContent) {
final javafx.stage.Stage actualAlertDialog = getTopModalStage();
assertNotNull(actualAlertDialog);
final DialogPane dialogPane = (DialogPane) actualAlertDialog.getScene().getRoot();
assertEquals(expectedHeader, dialogPane.getHeaderText());
assertEquals(expectedContent, dialogPane.getContentText());
}
private javafx.stage.Stage getTopModalStage() {
// Get a list of windows but ordered from top[0] to bottom[n] ones.
// It is needed to get the first found modal window.
final List<Window> allWindows = new ArrayList<>(robot.robotContext().getWindowFinder().listWindows());
Collections.reverse(allWindows);
return (javafx.stage.Stage) allWindows
.stream()
.filter(window -> window instanceof javafx.stage.Stage)
.filter(window -> ((javafx.stage.Stage) window).getModality() == Modality.APPLICATION_MODAL)
.findFirst()
.orElse(null);
}
I know this issue is a little old and probably got fixed, but for documentation purpose in case someone else look for a fix for an issue alike, I see dialog.getDialogPane() in Dialog documentation, which would help lookup for specific controls inside the pane. So further on #plaidshirt query, we could retrieve buttons and input fields with:
dialog.getDialogPane().lookupAll()
Then narrow that down to buttons and input fields for example.

How to change the value of a certain core data across VCs/ How to know the index of a created CoreData?

I start from a TableView to create and store user information. This is how I create a core data entity called "Trials" in CreateTrialViewController. And I can successfully fetch it in the tableViewController after I come back to it.
let trial : Trials = NSEntityDescription.insertNewObjectForEntityForName("Trials", inManagedObjectContext: self.managedObjectContext!) as? Trials
{
trial.project = theProject.text
trial.record = theRecord.text
trial.notes = theNotes.text
trial.percentile = ""
managedObjectContext?.save(nil)
}
'
But after I create the Trial, I will get some calculated results from the accelerometer in the next measureViewController, and I want to save the result into 'trial.percentile'.
I have already converted the results into a string, so I can write it directly into the core data attribute. But how can I know the index of this core data that I just created? Should I try to use 'segue' to transmit?
In the tableView it fetches in a ascending sequence of date, so the index is clear. But here in the following VC how to know the index? I still couldn't figure this out by myself... The sequence of my VCs is: TableViewController -> CreateTrialViewController -> MeasureViewController -> TableViewController (start again)
Your table view controller can keep a reference to the newly created object. Insert the object (trial) in the original view controller and pass it on to the next controller in prepareForSegue. So the CreateTrialViewController starts out with a blank object to which the table view controller has a reference.
You configure the object, go to the measure controller, modify the object. When done, you pop these two controllers from the navigation stack and are back in your original table view controller.
Because your table view controller has the NSFetchedResultsControllerDelegate enabled, it will update itself to reflect the data of your new object. Remember, you still have a reference to this object, so you can just use indexPathForObject to retrieve its index path.

how to get the name of an object and change the text of a textbox with its' name?

Hi there (developers of wp7 apps).
The following problem already caused countless sleepless nights, so i hope anyone could provide me with a solution.
Elements grouped as a grid should call (on tap) a function that changes a textbox' text with one i declare.
I already have the function that reads the "name" of the object:
private void FunctionABC(object sender, System.Windows.Input.GestureEventArgs e)
{
//Objects name
string ObjectSender = (sender as Grid).Name.ToString();
//But how to continue, if I want kind of "this" result?:
this.ObjectSender.Text = "abc";
}
I appreciate any answer my problem. Thanks.
If your question is how to change the textbox.text property which is placed inside a grid if you tap the grid then you should iterate through the grids Children and find the textbox you are looking for and then change it's text property.
First of all you need to change the this line :
string ObjectSender = (sender as Grid).Name.ToString();
because this line gives you the name of the Grid and not the Grid itself.
Grid ObjectSender = (Grid) sender;
And then you can search through it's children.

Resources