Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links

Java for iPhone with iSpectrum

Software Development

Thread Tools Search this Thread
Old 24-11-2010
Join Date: Sep 2010
Posts: 48
Java for iPhone with iSpectrum

I am giving an explanation by introducing 2 new classes UIKit: UIScrollView and UIPageControl. A scroll view is used to display content that is larger than the size allocated for this purpose (usually the entire screen). It supports the keys of the user can scroll the view by sweeping gestures (swiping gestures) or zoom in by pinching (pinch gesture to zoom). It draws nothing if not scroll bars vertical and horizontal and is used to hold other views. The graphical component (widget) Control page represents all views displayed by a line whose white point means the displayed frame. An example of use can be observed in managing tabs in Safari for iPhone. Required Softwares, To begin using iSpectrum, You Will Need to Have Installed On your computer:
  • Eclipse 3.4 (Ganymede) or 3.5 (Galileo)
    Recommended packages Eclipse IDE: Eclipse IDE for Java Developers gold annually Eclipse Java Development Tools (JDT) plugin (included in MOST Eclipse IDE packages).
  • JDK or JRE, version 5 or later
  • iPhone SDK
If JDK is already installed is your development computer, please take a moment to make sure that it meets the requirements recreational or version. In particular, that note some Linux distributions include may JDK 1.4 or gnu compiler for java, both of which are not supported for flexycore plug in.

Description :

This sample application allows the user to use a sweeping motion to navigate between 4 monochrome pages. This action brings up the next page with an animation of translation. Meanwhile component control page shows what the current page with a white dot.


This view is custom made from 2 sub-views: a scroll view and page view control.
public class MyView extends UIView { 

/ ** 

* Fields 

* / 

private Vector <UIViewController> viewControllers; 

Private UIScrollView ScrollView; 

Private UIPageControl PageControl;

Reply With Quote
Old 24-11-2010
Join Date: Sep 2010
Posts: 48
Re: Java for iPhone with iSpectrum

A Vector containing the list of our monochrome views are to be placed in the scroll view. Here's how they are created:
public MyView () { 

super (); 

initWithFrame (CGRect. CGRectMake (0, 0, 320, 380)); 

/ * 

* Construction Views 

* / 

Vector colors = new Vector <UIColor> <UIColor> (); 

colors.add (UIColor. blueColor ()); 

colors.add (UIColor. whiteColor ()); 

colors.add (UIColor. redColor ()); 

colors.add (UIColor. greenColor ()); 

viewControllers = new Vector <UIViewController> (); 

for (int i = 0; i <colors.size (); i + +) 


// New UIViewController 

UIViewController viewCtr UIViewController = new (); 

viewCtr.init (); 

// New UIView 

UIView view = new UIView (); 

view.initWithFrame (CGRect. CGRectMake (0, 0, 320, 380)); 

view.setBackgroundColor (colors.elementAt (i)); 

// Add a label 

UILabel UILabel label = new (); 

label.initWithFrame (CGRect. CGRectMake (0, 100, 320, 40)); 

label.setBackgroundColor (UIColor. clearColor ()); 

label.setTextColor (UIColor. blackColor ()); 

label.setTextAlignment (UITextAlignment. UITextAlignmentCenter); 

label.setText ("PAGE" + (i +1)); 

view.addSubview (label); 

viewCtr.setView (view); 

viewControllers. add (viewCtr); 

A UILabel is included on the page to indicate what page it is to see that the control page returns a good value.
/ * 

* PageControl 

* / 

PageControl UIPageControl = new () { 

@ Override 

public ControlEvent void () { 

changePage (this. currentPage ()); 



PageControl. initWithFrame (CGRect. CGRectMake (0, 385, 320, 31)); 

PageControl. setNumberOfPages (viewControllers. size ()); 

PageControl. setCurrentPage (0); 

PageControl. addTargetActionForControlEvents (UIControlEvents. UIControlEventValueChanged); 

addSubview (PageControl);
The page control is initialized to manage 4 pages, starting at page 0 and reacts to the event UIControlValueChanged. When this event occurs, its method ControlEvent () is called. This is how the paradigm UIKit Target-Action has been adapted to Java. This event is triggered whenever the currentPage attribute will be changed. We'll see where this is the case in the next section with the section of scroll view delegate. When this event occurs, it calls the method changePage ().
Reply With Quote
Old 24-11-2010
Join Date: Sep 2010
Posts: 48
Re: Java for iPhone with iSpectrum

/ ** 

* Change Of The content offset ScrollView To The new current page. 

* / 

public changePage void (int page) { 

CGPoint contentOffset CGPoint = new (); 

contentOffset.init (320 * page, 0); 

ScrollView. setContentOffsetAnimated (contentOffset, true); 

As the commentary suggests, the method is to change the offset of the scroll view that determines which of the views contained will be displayed. The offset is chosen to be a multiple of the width of the screen (320), which is also the width of sub-views. So that the pages are displayed one to one entirely. Returning now to the constructor: it now creates the scroll view.
/ * 

* Scroll setting properties 

* / 

ScrollView UIScrollView = new (); 

ScrollView. initWithFrame (CGRect. CGRectMake (0, 0, 320, 380)); 

float W = this. frame (). getSize (). getWidth () * viewControllers. size (); 

float H = this. frame (). getSize (). getHeight (); 

ScrollView. setContentSize (new CGSize (). init (W, H)); 

ScrollView. setPagingEnabled (true); 

ScrollView. setShowsHorizontalScrollIndicator (false); 

ScrollView. setShowsVerticalScrollIndicator (false); 

ScrollView. setScrollsToTop (false); 

ScrollView. setUIScrollViewDelegate (new ScrollDelegate (this)); 

addSubview (ScrollView);
The frame of the view is set to full screen and contentSize attribute to define the display area of sub-views. Then pagingEnabled is set to true which has the effect of stopping the animation scroll pages in multiples of the size of the view. As this corresponds to sub-views, it has a "page by page. Then, we associate a custom delegate and then added to the current view. Finally we load all pages.
/ / Load all views 

for (int i = 0; i <viewControllers. size (); i + +) { 

loadScrollViewWithPage (i); 


Let's see what it is: 

public loadScrollViewWithPage void (int page) { 

if (page <0) return; 

if (page> = viewControllers. size ()) return; 

UIViewController ViewController = viewControllers. ElementAt (page); 

if (ViewController == null) return; 

/ / Add The Controller's View To The scroll view 

if (viewController.view (). SuperView () == null) { 

CGRect frame = this. Frame (); 

frame.setOrigin (new CGPoint (). init (frame.getSize (). getWidth () * page, 0)); 

viewController.view (). setFrames (frame); 

ScrollView. addSubview (viewController.view ()); 


This method creates the sub-views, side by side in the scroll view contentView from screens created and developed in Vector viewControllers. This callback method is called at the end of the animation page change that has previously enabled through pagingEnabled true. In this method we look at the offset of the scroll view to know the current page and thus update the page control. This will cause an event type UIControlValueChanged. The following image shows what happens when calling setCurrentPage () is called. You now know how to integrate scanning movement in your applications to handle more pages using UIScrollView class and associating it with the page control. You can give thanks to that render iPhone standard applications.
Reply With Quote
Old 25-11-2010
Posts: n/a
Re: Java for iPhone with iSpectrum

I have use it and get lots of benefits in my business.
Wapframe.com is a new york based mobile site builder company. We at Wapframe.com offer latest and user friendly tools for website. If you want too cheap and best mobile web application then you can contact with me at

Last edited by Maqbool : 26-11-2010 at 01:00 AM. Reason: External Links Not Allowed, Removed The Same.
Reply With Quote

  TechArena Community > Software > Software Development
Tags: , , , , ,

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads for: "Java for iPhone with iSpectrum"
Thread Thread Starter Forum Replies Last Post
Java Auto Updater wants me to update java everyday in Windows 7 minajoh Windows Software 4 04-09-2013 11:04 PM
Download and install java games in Chinese iPhone - model PT 168 A_x_Dos Portable Devices 12 14-01-2012 01:50 AM
Link List Example in Java Sample program in Java trickson Software Development 2 04-08-2009 08:23 PM
how to activate java in mini iphone m531g?? banbanme Portable Devices 1 18-06-2009 10:57 PM

All times are GMT +5.5. The time now is 01:44 AM.