Search Results

Search found 1119 results on 45 pages for 'tableview'.

Page 5/45 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • iPhone TableView alternative options for Check Mark Accessory

    - by jimsis
    I'm looking for the best approach to this problem. In my tableview I have a list of options from which you can select one and only one. The problem is the selection to choose is not obvious without displaying more details on the option. If I use the disclosure indicator or button for the more detail, I lose the checkmark functionality. In searching around I see some have used the cell Image as a work around. I see others instead of using the standard disclosure button have created custom disclosure button looking like a checkmark. Haven't seen this one but is it viable (HIG) to add a button in the cell ('more info') to launch the next tableview. My thought was to use a disclosure indicator and on the second view in the navigation bar (where the edit button usually is) add a 'selectMe' button. I think I am probably manage to code either of the above, am just asking for information on what is the best (HIG) way. Example Option 1 Option 2 Option 3 (x) Option 4 Where x is the checked one But in order to know which is the best choice you need to see Option 3 (Header) Option 3-a Option 3-b Option 3-c Option 3-d Where even at this level option 3-c might have additional information. Any guidance you can provide would appreciated.

    Read the article

  • iphone reload tableView

    - by Brodie4598
    In the following code, I have determined that everything works, up until [tableView reloadData] i have NSLOGs set up in the table view delegate methods and none of them are getting called. I have other methods doing the same reloadData and it works perfectly. The only difference tha I am awayre of is tha this is in a @catch block. maybe you smart guys can see something i'm doing wrong... @catch (NSException * e) {////chart is user genrated logoView.image = nil; NSInteger row = [picker selectedRowInComponent:0]; NSString *selectedAircraft = [aircraft objectAtIndex:row]; NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *docsPath = [paths objectAtIndex:0]; NSString *checklistPath = [[NSString alloc]initWithFormat:@"%@/%@.checklist",docsPath,selectedAircraft]; NSString *dataString = [NSString stringWithContentsOfFile:checklistPath encoding: NSUTF8StringEncoding error:NULL]; if ([dataString hasPrefix:@"\n"]) { dataString = [dataString substringFromIndex:1]; } NSArray *tempArray = [dataString componentsSeparatedByString:@"\n"]; NSDictionary *temporaryDictionary = [NSDictionary dictionaryWithObject: tempArray forKey:@"User Generated Checklist"]; self.names = temporaryDictionary; NSArray *tempArray2 = [NSArray arrayWithObject:@"01User Generated Checklist"]; self.keys = tempArray2; aircraftLabel.text = selectedAircraft; checklistSelectPanel.hidden = YES; [tableView reloadData]; }

    Read the article

  • Iphone: TabView + TableView

    - by OneTrickPonySoft
    I think I'm missing something simple, but I can't figure out exactly what it is. I'm trying to set up an App with a UITabViewController, and one of the Tabs will have a UITableView and UISearchBar (but no Navigation Controller). I set up the UITabViewController with all the tabs in interface builder, and the views are in their own xib files. The xib file for the tab with the UITableView is set up and connected as follows. Stuff in the browser: File's owner (Class is my custom class that is a child of UITableViewController) view - View View (class UIView, reference view - File's owner) contains: UITableView (if i try and set references to the data source / delegate, the app breaks) UISearchBar (unconfigured at the moment) This setup displays all the items and doesn't lock up, but I can't assign a DataSource without it crashing when i try and load the tab with the UITableView. What should I do to get data into this table, either in IB or code? My ideas are as follows: Implement custom UITableView class, hook up to table view in IB or to custom tableviewcontroller in Xcode. Pound head or laptop against the wall until it works. Update: Here's the error the simulator pushes to the console when I connect the Tableview's data source and delegate to File Owner (who's class is my custom tableviewcontroller). 2/14/09 6:59:12 PM TabBarWillbeRight[33172] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x523760'

    Read the article

  • How to display different value with ComboBoxTableCell?

    - by Philippe Jean
    I try to use ComboxBoxTableCell without success. The content of the cell display the right value for the attribute of an object. But when the combobox is displayed, all items are displayed with the toString object method and not the attribute. I tryed to override updateItem of ComboBoxTableCell or to provide a StringConverter but nothing works. Do you have some ideas to custom comboxbox list display in a table cell ? I put a short example below to see quickly the problem. Execute the app and click in the cell, you will see the combobox with toString value of the object. package javafx2; import javafx.application.Application; import javafx.beans.property.adapter.JavaBeanObjectPropertyBuilder; import javafx.beans.value.ObservableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.Scene; import javafx.scene.control.TableCell; import javafx.scene.control.TableColumn; import javafx.scene.control.TableColumn.CellDataFeatures; import javafx.scene.control.TableView; import javafx.scene.control.cell.ComboBoxTableCell; import javafx.stage.Stage; import javafx.util.Callback; import javafx.util.StringConverter; public class ComboBoxTableCellTest extends Application { public class Product { private String name; public Product(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } } public class Command { private Integer quantite; private Product product; public Command(Product product, Integer quantite) { this.product = product; this.quantite = quantite; } public Integer getQuantite() { return quantite; } public void setQuantite(Integer quantite) { this.quantite = quantite; } public Product getProduct() { return product; } public void setProduct(Product product) { this.product = product; } } public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { Product p1 = new Product("Product 1"); Product p2 = new Product("Product 2"); final ObservableList<Product> products = FXCollections.observableArrayList(p1, p2); ObservableList<Command> commands = FXCollections.observableArrayList(new Command(p1, 20)); TableView<Command> tv = new TableView<Command>(); tv.setItems(commands); TableColumn<Command, Product> tc = new TableColumn<Command, Product>("Product"); tc.setMinWidth(140); tc.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Command,Product>, ObservableValue<Product>>() { @Override public ObservableValue<Product> call(CellDataFeatures<Command, Product> cdf) { try { JavaBeanObjectPropertyBuilder<Product> jbdpb = JavaBeanObjectPropertyBuilder.create(); jbdpb.bean(cdf.getValue()); jbdpb.name("product"); return (ObservableValue) jbdpb.build(); } catch (NoSuchMethodException e) { System.err.println(e.getMessage()); } return null; } }); final StringConverter<Product> converter = new StringConverter<ComboBoxTableCellTest.Product>() { @Override public String toString(Product p) { return p.getName(); } @Override public Product fromString(String s) { // TODO Auto-generated method stub return null; } }; tc.setCellFactory(new Callback<TableColumn<Command,Product>, TableCell<Command,Product>>() { @Override public TableCell<Command, Product> call(TableColumn<Command, Product> tc) { return new ComboBoxTableCell<Command, Product>(converter, products) { @Override public void updateItem(Product product, boolean empty) { super.updateItem(product, empty); if (product != null) { setText(product.getName()); } } }; } }); tv.getColumns().add(tc); tv.setEditable(true); Scene scene = new Scene(tv, 140, 200); stage.setScene(scene); stage.show(); } }

    Read the article

  • tableView:didSelectRowAtIndexPath: calls TTNavigator openURLAction:applyAnimated: — UITabBar and na

    - by vikingosegundo
    I have an existing iphone project with a UITabBar. Now I need styled text and in-text links to other ViewControllers in my app. I am trying to integrate TTStyledTextLabel. I have a FirstViewController:UITabelViewController with this tableView:didSelectRowAtIndexPath: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *url; if ([self.filteredQuestions count]>0) { url = [NSString stringWithFormat:@"%@%d", @"tt://question/", [[self.filteredQuestions objectAtIndex:indexPath.row] id]]; [[TTNavigator navigator] openURLAction:[[TTURLAction actionWithURLPath: url] applyAnimated:YES]]; } else { Question * q = [self.questions objectAtIndex:indexPath.row] ; url = [NSString stringWithFormat:@"%@%d", @"tt://question/", [q.id intValue]]; } TTDPRINT(@"%@", url); TTNavigator *navigator = [TTNavigator navigator]; [navigator openURLAction:[[TTURLAction actionWithURLPath: url] applyAnimated:YES]]; } My mapping looks like this: TTNavigator* navigator = [TTNavigator navigator]; navigator.window = window; navigator.supportsShakeToReload = YES; TTURLMap* map = navigator.URLMap; [map from:@"*" toViewController:[TTWebController class]]; [map from:@"tt://question/(initWithQID:)" toViewController:[QuestionDetailViewController class]]; and my QuestionDetailViewController: @interface QuestionDetailViewController : UIViewController <UIScrollViewDelegate , QuestionDetailViewProtocol> { Question *question; } @property(nonatomic,retain) Question *question; -(id) initWithQID:(NSString *)qid; -(void) goBack:(id)sender; @end When I hit a cell, q QuestionDetailViewController will be called — but the navigationBar wont @implementation QuestionDetailViewController @synthesize question; -(id) initWithQID:(NSString *)qid { if (self = [super initWithNibName:@"QuestionDetailViewController" bundle:nil]) { //; TTDPRINT(@"%@", qid); NSManagedObjectContext *managedObjectContext = [(domainAppDelegate*)[[UIApplication sharedApplication] delegate] managedObjectContext]; NSPredicate *predicate =[NSPredicate predicateWithFormat:@"id == %@", qid]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Question" inManagedObjectContext:managedObjectContext]; NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:entity]; [request setPredicate:predicate]; NSError *error = nil; NSArray *array = [managedObjectContext executeFetchRequest:request error:&error]; if (error==nil && [array count]>0 ) { self.question = [array objectAtIndex:0]; } else { TTDPRINT(@"error: %@", array); } } return self; } - (void)viewDidLoad { [super viewDidLoad]; [TTStyleSheet setGlobalStyleSheet:[[[TextTestStyleSheet alloc] init] autorelease]]; [self.navigationController.navigationBar setTranslucent:YES]; NSArray *includedLinks = [self.question.answer.text vs_extractExternalLinks]; NSMutableDictionary *linksToTT = [[NSMutableDictionary alloc] init]; for (NSArray *a in includedLinks) { NSString *s = [a objectAtIndex:3]; if ([s hasPrefix:@"/answer/"] || [s hasPrefix:@"http://domain.com/answer/"] || [s hasPrefix:@"http://www.domain.com/answer/"]) { NSString *ttAdress = @"tt://question/"; NSArray *adressComps = [s pathComponents]; for (NSString *s in adressComps) { if ([s isEqualToString:@"qid"]) { ttAdress = [ttAdress stringByAppendingString:[adressComps objectAtIndex:[adressComps indexOfObject:s]+1]]; } } [linksToTT setObject:ttAdress forKey:s]; } } for (NSString *k in [linksToTT allKeys]) { self.question.answer.text = [self.question.answer.text stringByReplacingOccurrencesOfString:k withString: [linksToTT objectForKey:k]]; } TTStyledTextLabel *answerText = [[[TTStyledTextLabel alloc] initWithFrame:CGRectMake(0, 0, 320, 700)] autorelease]; if (![[self.question.answer.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] hasPrefix:@"<div"]) { self.question.answer.text = [NSString stringWithFormat:@"%<div>%@</div>", self.question.answer.text]; } NSString * s = [NSString stringWithFormat:@"<div class=\"header\">%@</div>\n%@",self.question.title ,self.question.answer.text]; answerText.text = [TTStyledText textFromXHTML:s lineBreaks:YES URLs:YES]; answerText.contentInset = UIEdgeInsetsMake(20, 15, 20, 15); [answerText sizeToFit]; [self.navigationController setNavigationBarHidden:NO animated:YES]; [self.view addSubview:answerText]; [(UIScrollView *)self.view setContentSize:answerText.frame.size]; self.view.backgroundColor = [UIColor whiteColor]; [linksToTT release]; } ....... @end This works quite nice, as soon as a cell is touched, a QuestionDetailViewController is called and pushed — but the tabBar will disappear, and the navigationItem — I set it like this: self.navigationItem.title =@"back to first screen"; — won't be shown. And it just appears without animation. But if I press a link inside the TTStyledTextLabel the animation works, the navigationItem will be shown. How can I make the animation, the navigationItem and the tabBar be shown?

    Read the article

  • Dynamically create hierachical tableview from file structure

    - by Rob M
    Hi, I have a directory structure of directories and files that I want to render as a tableview in an iphone app. I'd rather have this generated dynamically rather than have to maintain a XML PLIST or whatever. i.e. replicate the Explorer functionality in windows where a user can traverse the structure and then select bundled image files for viewing. Is there any way to do this? Any advice would be appreicated.

    Read the article

  • TableView SwipeGesture

    - by venkat
    hi every one.i am using TableView having edit button to delete a row.when i swipe in the row it shows a default "Delete" button. But i dont need it.The Content of the cell must be deleted by means of edit button not by default one.how to disable that "Swipe to Delete" Button.

    Read the article

  • how to remove seperator from tableview

    - by thndrkiss
    Hi, I used interface builder and changed my tableview style as grouped and seperator as none. I was able to see the change in the display style which is grouped right now. But The seperator change is not getting reflected. Kindly help me how to remove the seperator.

    Read the article

  • Change table view ( tableview style grouped ) background color ?

    - by Madhup
    Hi all, I am developing an iPad application in which I need a table view ( style grouped ) having background color as clearColor. My problem is [self.tableView setBackgroundColor:[UIColor clearColor]]; works well if the table view style is plain but when I switch to group table view the background color does not changes it stays gray in color. FYI: the contentview background color of tableviewcell also does not change. Is this a bug in iPhone-sdk or I am doing something wrong. Thanks, Madhup

    Read the article

  • Go back to main window once secondView is loaded

    - by Ruthy
    Hi, I have a Tableview on AppDelegate That calls a SecondView (dvController) when DidSelectRowAtIndexPath using: [self.window addSubview:[dvController view]]; On SecondView I defined a button linked to IBAction that should go back to previous view. It works great but when row selected but, How could then go back to previous view if main one is AppDelegate? self.window addSubview:[?? view]]; Should be basic concept but I am quite new and unable to get the solution. Thanx :)

    Read the article

  • UITableView madness

    - by kesrut
    Hello, I'm new to iPhone application development. I'm trying to understand how to use UITableView. I'm wrote simple code: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 1 ; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease]; } cell.textLabel.text = @"Hello"; return cell; } UITable shows content, but if i'm drag table contents my application terminates. You can see video: http://www.youtube.com/watch?v=TucTVJVhSD0 I tried to everything with array: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1 ; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [hello count] ; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease]; } cell.textLabel.text = [hello objectAtIndex:indexPath.row]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:NO]; NSLog(@"Selected") ; } - (void) awakeFromNib { hello = [[NSArray alloc] initWithObjects:@"hello", @"world", @"end", nil]; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; } Content is shown and if I'm selecting item i'm getting: [Session started at 2010-03-16 19:21:48 +0200.] 2010-03-16 19:21:52.295 ViewTest[1775:207] * -[ViewTestViewController respondsToSelector:]: message sent to deallocated instance 0x3911ec0 I'm total new to iPhone programming. And as i see everything i do - i'm just getting application terminated ..

    Read the article

  • appcelerator tableview autosliding

    - by matthewb
    Using Appcelerator: I have a form, a tableView with textFeilds I want it so when I focus on them, it slides the window or the view to the top, under the navigation bar. Right now, the keyboard is blocking the last few rows. Do I need a listener on each form to slide? If so how do you do that?

    Read the article

  • Fetch a label from tableView cell iphone sdk

    - by neha
    Hi all, In my application I'm adding a label to tableView cells using "cell addsubview" and not "cell.contentview addsubview". I'm assigning a tag to that label, but I'm not able to fetch it using "cell.contentView viewWithTag:1". I perfectly understand that the label is not on contentView, but then how do I fetch it? Thanks in advance.

    Read the article

  • UITableView: Handle cell selection in a mixed cell table view static and dynamic cells

    - by AlexR
    I am trying to mix dynamic and static cells in a grouped table view: I would like to get two sections with static cells at the top followed by a section of dynamic cells (please refer to the screenshot below). I have set the table view contents to static cells. Edit Based on AppleFreak's advice I have changed my code as follows: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell; if (indexPath.section <= 1) { // section <= 1 indicates static cells cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; } else { // section > 1 indicates dynamic cells CellIdentifier = [NSString stringWithFormat:@"section%idynamic",indexPath.section]; cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; } return cell; } However, my app crashes with error message Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:' for section 0 and row 0. The cell returned from cell = [super tableView:tableView cellForRowAtIndexPath:indexPath] for section 0 and row 0 is nil. What is wrong with my code? Could there be any problems with my outlets? I haven't set any outlets because I am subclassing UITableViewController and supposedly do not any outlets for tableview to be set (?). Any suggestions on how to better do it? Edit II I have recreated my scene in storyboard (please refer to my updated screen shot above) and rewritten the view controller in order to start from a new base. I have also read the description in Apple's forum as applefreak suggested. However, I run in my first problem with the method numberOfSectionsInTableView:tableView, in which I increment the number of static sections (two) by one. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [super numberOfSectionsInTableView:tableView] + 1 ; } The app crashed with the error message: Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayI objectAtIndex:]: index 2 beyond bounds [0 .. 1]' Why is this code not working for me even though I followed Apple's and applefreak recommendations? It is possible that the tableView has changed a bit in iOS 6? Solution: I got this to work now using AppleFreaks code sample in his answer below. Thank you, AppleFreak! Edit III: Cell Selection: How can I handle cell selection in a mixed (dynamic and static cells) cell table view? When do I call super and when do I call self tableView? When I use [[super tableView] selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone] and try to check for the selected index paths with: UITableView *tableView = [super tableView]; if ( [[tableView indexPathForSelectedRow] isEqual:customGrowthIndexPath] ) { .. } I get an return value of nil. As I can't find the source of my error, I really would appreciate your help

    Read the article

  • Reach the end of the tableview without using 'numberOfRowsInSection' delegate method iphone sdk

    - by neha
    Hi all, I want to add a view after the last cell of tableview. I need to define the frame for it. If I want to add something before the first cell, then I can set the frame as refreshHeaderView = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.view.bounds.size.height,320.0f, self.view.bounds.size.height)]; But how to find the y coordinate of the frame of view to be set after the last cell. Thanx in advance.

    Read the article

  • TableView with section & Index

    - by iavian
    could anyone point me to some examples on how to achieve Tableview with section and Index on Section. Similar to one it's in iPhone = http://www.iphonesdkarticles.com/2009/01/uitableview-indexed-table-view.html

    Read the article

  • JavaFx 2.1, 2.2 TableView update issue

    - by Lewis Liu
    My application uses JPA read data into TableView then modify and display them. The table refreshed modified record under JavaFx 2.0.3. Under JavaFx 2.1, 2.2, the table wouldn't refresh the update anymore. I found other people have similar issue. My plan was to continue using 2.0.3 until someone fixes the issue under 2.1 and 2.2. Now I know it is not a bug and wouldn't be fixed. Well, I don't know how to deal with this. Following are codes are modified from sample demo to show the issue. If I add a new record or delete a old record from table, table refreshes fine. If I modify a record, the table wouldn't refreshes the change until a add, delete or sort action is taken. If I remove the modified record and add it again, table refreshes. But the modified record is put at button of table. Well, if I remove the modified record, add the same record then move the record to the original spot, the table wouldn't refresh anymore. Below is a completely code, please shine some light on this. import javafx.application.Application; import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.HPos; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.scene.text.Font; import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.StageStyle; public class Main extends Application { private TextField firtNameField = new TextField(); private TextField lastNameField = new TextField(); private TextField emailField = new TextField(); private Stage editView; private Person fPerson; public static class Person { private final SimpleStringProperty firstName; private final SimpleStringProperty lastName; private final SimpleStringProperty email; private Person(String fName, String lName, String email) { this.firstName = new SimpleStringProperty(fName); this.lastName = new SimpleStringProperty(lName); this.email = new SimpleStringProperty(email); } public String getFirstName() { return firstName.get(); } public void setFirstName(String fName) { firstName.set(fName); } public String getLastName() { return lastName.get(); } public void setLastName(String fName) { lastName.set(fName); } public String getEmail() { return email.get(); } public void setEmail(String fName) { email.set(fName); } } private TableView<Person> table = new TableView<Person>(); private final ObservableList<Person> data = FXCollections.observableArrayList( new Person("Jacob", "Smith", "[email protected]"), new Person("Isabella", "Johnson", "[email protected]"), new Person("Ethan", "Williams", "[email protected]"), new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]")); public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Table View Sample"); stage.setWidth(535); stage.setHeight(535); editView = new Stage(); final Label label = new Label("Address Book"); label.setFont(new Font("Arial", 20)); TableColumn firstNameCol = new TableColumn("First Name"); firstNameCol.setCellValueFactory( new PropertyValueFactory<Person, String>("firstName")); firstNameCol.setMinWidth(150); TableColumn lastNameCol = new TableColumn("Last Name"); lastNameCol.setCellValueFactory( new PropertyValueFactory<Person, String>("lastName")); lastNameCol.setMinWidth(150); TableColumn emailCol = new TableColumn("Email"); emailCol.setMinWidth(200); emailCol.setCellValueFactory( new PropertyValueFactory<Person, String>("email")); table.setItems(data); table.getColumns().addAll(firstNameCol, lastNameCol, emailCol); //--- create a edit button and a editPane to edit person Button addButton = new Button("Add"); addButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { fPerson = null; firtNameField.setText(""); lastNameField.setText(""); emailField.setText(""); editView.show(); } }); Button editButton = new Button("Edit"); editButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { if (table.getSelectionModel().getSelectedItem() != null) { fPerson = table.getSelectionModel().getSelectedItem(); firtNameField.setText(fPerson.getFirstName()); lastNameField.setText(fPerson.getLastName()); emailField.setText(fPerson.getEmail()); editView.show(); } } }); Button deleteButton = new Button("Delete"); deleteButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { if (table.getSelectionModel().getSelectedItem() != null) { data.remove(table.getSelectionModel().getSelectedItem()); } } }); HBox addEditDeleteButtonBox = new HBox(); addEditDeleteButtonBox.getChildren().addAll(addButton, editButton, deleteButton); addEditDeleteButtonBox.setAlignment(Pos.CENTER_RIGHT); addEditDeleteButtonBox.setSpacing(3); GridPane editPane = new GridPane(); editPane.getStyleClass().add("editView"); editPane.setPadding(new Insets(3)); editPane.setHgap(5); editPane.setVgap(5); Label personLbl = new Label("Person:"); editPane.add(personLbl, 0, 1); GridPane.setHalignment(personLbl, HPos.LEFT); firtNameField.setPrefWidth(250); lastNameField.setPrefWidth(250); emailField.setPrefWidth(250); Label firstNameLabel = new Label("First Name:"); Label lastNameLabel = new Label("Last Name:"); Label emailLabel = new Label("Email:"); editPane.add(firstNameLabel, 0, 3); editPane.add(firtNameField, 1, 3); editPane.add(lastNameLabel, 0, 4); editPane.add(lastNameField, 1, 4); editPane.add(emailLabel, 0, 5); editPane.add(emailField, 1, 5); GridPane.setHalignment(firstNameLabel, HPos.RIGHT); GridPane.setHalignment(lastNameLabel, HPos.RIGHT); GridPane.setHalignment(emailLabel, HPos.RIGHT); Button saveButton = new Button("Save"); saveButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { if (fPerson == null) { fPerson = new Person( firtNameField.getText(), lastNameField.getText(), emailField.getText()); data.add(fPerson); } else { int k = -1; if (data.size() > 0) { for (int i = 0; i < data.size(); i++) { if (data.get(i) == fPerson) { k = i; } } } fPerson.setFirstName(firtNameField.getText()); fPerson.setLastName(lastNameField.getText()); fPerson.setEmail(emailField.getText()); data.set(k, fPerson); table.setItems(data); // The following will work, but edited person has to be added to the button // // data.remove(fPerson); // data.add(fPerson); // add and remove refresh the table, but now move edited person to original spot, // it failed again with the following code // while (data.indexOf(fPerson) != k) { // int i = data.indexOf(fPerson); // Collections.swap(data, i, i - 1); // } } editView.close(); } }); Button cancelButton = new Button("Cancel"); cancelButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { editView.close(); } }); HBox saveCancelButtonBox = new HBox(); saveCancelButtonBox.getChildren().addAll(saveButton, cancelButton); saveCancelButtonBox.setAlignment(Pos.CENTER_RIGHT); saveCancelButtonBox.setSpacing(3); VBox editBox = new VBox(); editBox.getChildren().addAll(editPane, saveCancelButtonBox); Scene editScene = new Scene(editBox); editView.setTitle("Person"); editView.initStyle(StageStyle.UTILITY); editView.initModality(Modality.APPLICATION_MODAL); editView.setScene(editScene); editView.close(); final VBox vbox = new VBox(); vbox.setSpacing(5); vbox.getChildren().addAll(label, table, addEditDeleteButtonBox); vbox.setPadding(new Insets(10, 0, 0, 10)); ((Group) scene.getRoot()).getChildren().addAll(vbox); stage.setScene(scene); stage.show(); } }

    Read the article

  • data not reloading into tableview from core data on minor update

    - by Martin KS
    I've got a basic photo album application, on the first view a list of albums is displayed with a subtitle showing how many images are in each album. I've got everything working to add albums, and add images to albums. The problem is that the image count lines are accurate whenever the app loads, but I can't get them to update during execution. The following viewdidload correctly populates all lines of the tableview when the app loads: - (void)viewDidLoad { [super viewDidLoad]; // Set the title. self.title = @"Photo albums"; // Configure the add and edit buttons. self.navigationItem.leftBarButtonItem = self.editButtonItem; addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addAlbum)]; addButton.enabled = YES; self.navigationItem.rightBarButtonItem = addButton; /* Fetch existing albums. Create a fetch request; find the Album entity and assign it to the request; add a sort descriptor; then execute the fetch. */ NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Album" inManagedObjectContext:managedObjectContext]; [request setEntity:entity]; // Order the albums by name. NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"albumName" ascending:NO]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; [sortDescriptor release]; [sortDescriptors release]; // Execute the fetch -- create a mutable copy of the result. NSError *error = nil; NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy]; if (mutableFetchResults == nil) { // Handle the error. } LocationsAppDelegate *mainDelegate = (LocationsAppDelegate *)[[UIApplication sharedApplication] delegate]; // Set master albums array to the mutable array, then clean up. [mainDelegate setAlbumsArray:mutableFetchResults]; [mutableFetchResults release]; [request release]; } But when I run similar code inside viewdidappear, nothing happens: { /* Fetch existing albums. Create a fetch request; find the Album entity and assign it to the request; add a sort descriptor; then execute the fetch. */ NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Album" inManagedObjectContext:managedObjectContext]; [request setEntity:entity]; // Order the albums by creation date, most recent first. NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"albumName" ascending:NO]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [request setSortDescriptors:sortDescriptors]; [sortDescriptor release]; [sortDescriptors release]; // Execute the fetch -- create a mutable copy of the result. NSError *error = nil; NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy]; if (mutableFetchResults == nil) { // Handle the error. } LocationsAppDelegate *mainDelegate = (LocationsAppDelegate *)[[UIApplication sharedApplication] delegate]; // Set master albums array to the mutable array, then clean up. [mainDelegate setAlbumsArray:mutableFetchResults]; [self.tableView reloadData]; [mutableFetchResults release]; [request release]; } Apologies if I've missed the answer to this question elsewhere, but what am I missing?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >