iSpectrum-2 with Java programs written iPhone

sponsored links
iSpectrum-written with the Java program an iPhone

Download the official demo available

iSpectrum-2 with Java programs written iPhone


First analysis of iSpectrum the framework of official demo

1 Launcher is the program entry, similar to the main.m, in fact the code is almost Deconstruction

  public void applicationDidFinishLaunching(UIApplication app)
        { 
                UIWindow window = new UIWindow();
                window.initWithFrame(UIScreen.mainScreen().bounds());

                nav = new UINavigationController();
                
                UIViewController ctr = new UIViewController();
                ctr.init();
                ctr.setTitle("Action sheet");
                ctr.setView(new MainView(nav));
                
                nav.initWithRootViewController(ctr);
                
                window.addSubview(nav.view());
                window.makeKeyAndVisible();
        }

2 see mainview, no delloc really feel so cool, but absence of nib, so it can only initWithFrame added component of the original.

public class MainView extends UIView {
        /**
         * Fields
         */
        private UIActionSheet actionSheet;
        private UINavigationController nav;
        
        /**
         * 
         * @param n             UINavigationController containing this view.
         */
        public MainView(UINavigationController n){
                super();
                init();
                nav = n;
                
                /*
                 * ActionSheet
                 */
                actionSheet = new UIActionSheet();
                actionSheet.init();
                actionSheet.setActionSheetStyle(UIActionSheetStyle.UIActionSheetStyleBlackOpaque);
                actionSheet.setDelegate(new ActionSheetDelegate(this));
                actionSheet.setTitle("How many items do you want to display ?");
                actionSheet.addButtonWithTitle("Cancel");
                actionSheet.setCancelButtonIndex(0);
                actionSheet.dismissWithClickedButtonIndexAnimated(0, true);
                actionSheet.addButtonWithTitle("One item");
                actionSheet.addButtonWithTitle("Two items");
                actionSheet.addButtonWithTitle("Three items");
                actionSheet.addButtonWithTitle("Four items");
                
                /*
                 * Button
                 * Being used to open the UIActionSheet.
                 */
                UIButton button = new UIButton(){
                        //@Override
                        public void controlEvent() {
                                // Display the UIActionSheet
                                actionSheet.showInView(this.superview());
                        }
                };
                button.initWithFrame(CGRect.CGRectMake(85, 30, 150, 31));
                button.setBackgroundImageForState(UIImage.imageNamed("buttonBackground.tiff"), 0);
                button.setTitleForState("Create view", 0);
                button.setTitleColorForState(UIColor.blackColor(), 0);
                button.addTargetActionForControlEvents(UIControlEvents.UIControlEventTouchUpInside);
                addSubview(button);
        }
        
        /**
         * 
         * @return      nav             Current UINavigationController.
         */
        public UINavigationController getNavigationController(){
                return nav;
        }

}

Class 3 also have delegation

public class ActionSheetDelegate extends UIActionSheetDelegate {
        /**
         * Field
         */
        private MainView view;
        
        /**
         * 
         * @param v             MainView that create this object.
         */
        public ActionSheetDelegate(MainView v){
                super();
                init();
                view = v;
        }
        
        /**
         * Method called by system when user select a button on action sheet.
         * @param actionSheet           ActionSheet calling this method.
         * @param buttonIndex           Index of selected button.
         * 
         */
        //@Override
        public void actionSheetClickedButtonAtIndex(UIActionSheet actionSheet,
                        int buttonIndex) {
                if(buttonIndex == 0){
                        // Click on "cancel" button
                        return;
                }
                else {
                        UIView newView = new UIView().init();
                        
                        // Add to the new UIView as many subviews as user wants.
                        for(int i=1; i<=buttonIndex; i++){
                                UIImageView imageView = new UIImageView();
                                imageView.initWithFrame(CGRect.CGRectMake(i*40, 100, 30, 30));
                                imageView.setImage(UIImage.imageNamed("img"+i+".tiff"));
                                newView.addSubview(imageView);
                        }
                        
                        UIViewController viewController = new UIViewController().init();
                        if(buttonIndex == 1)
                                viewController.setTitle(buttonIndex + " added item");
                        else
                                viewController.setTitle(buttonIndex + " added items");
                        viewController.setView(newView);
                        
                        // Push this new view into UINavigationController stack.
                        view.getNavigationController().pushViewControllerAnimated(viewController, false);
                }
        }
        
}

From simple demo seems useful to see the need java, since java completely unable to use, many features and open source code, but also by the plug-in developer's restrictions.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of iSpectrum-2 with Java programs written iPhone

  • hibernate query cache

    hibernate query cache Query cache is cached result set of common property On the entity object cache only the result set id Query cache life cycle, when the associated table happened to amend, then the query cache of the life cycle of The End Query cache

  • hibernate how to store binary, image and other major fields.

    model categories: reportByte binary type for the database fields. public class PfReportStyle implements java.io.Serializable , Cloneable { // Fields /** * */ private static final long serialVersionUID = 1L; private Long id; private byte[] reportByte; // C

  • ror development environment to build

    Ror about the development environment set up, records are as follows. 1. Netbeans6.5 installation download netbeans6.5 address http://zh-cn.netbeans.org/download/6.5/ml/ Ruby can download a separate version that only around 50M. II. Ruby set up the e ...

  • jdbc even ORACLE, SQLServer2000, mysql ways

    According to other people say can make a ride to one of the clear step by step, not as easy to write your own ideas! 1. Even the oracle The direct use of the oracle are provided give a jar package jdbc: oracle alone is installed, and 10g of oracle on ...

  • hibernate study of the second

    Persistence of three main points: 1, a statement for persistent fields accessors (accessors) and whether the variable signs (mutators) Property statement is not necessarily required for the public's. Hibernate can be default, protected or private ...

  • Rails2.0.2 change the default DB adpter

    In Rails2.0.2 rails demo ... ... MissingSourceFile in SayController # hello no such file to load - sqlite3 RAILS_ROOT: / home / kenb / rails-projects / demo ... ... Checked config / database.yml, adpter default is set become the sqlite3. Check the ra ...

  • hibernate (jpa) composite primary key annotation statement Ways

    In the design of the database tables are designed with a composite primary key of the table, that table's record by more than one field joint identification, such as: Table CREATE TABLE TB_HOUR_DATA ( STAT_DATE DATE NOT NULL, PATH_ID NUMBER(20) NOT NULL,

  • jboss ejb3 Message Driven Bean

    Super Medium ejb hate. . . . . . . . . . . . . . . . . . . ================================================ To configure a Message Driven Bean in a different application server parameters are not the same. Currently only passed the test jboss. Message Dri

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Spring2.0 + hibernate3.1 + log4j + mysql demo

    applicationContext.xml Non-attachment jar package, necessary friends can send an email to todd.liangt @ gmail.com

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries