Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 8:49 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: j2me
PostPosted: Wed Sep 07, 2011 3:25 pm 

Sir,
Please tell mo how to append five different list element on a single list, and the selected element appends only once.


TOP
  
Reply with quote  
 Question subject: Re: j2me
PostPosted: Thu Sep 08, 2011 9:10 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time
I don't understand clearly your question , here is example on using list component in J2me :
Code:


/* License
 * 
 * Copyright 1994-2004 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *  
 *  * Redistribution of source code must retain the above copyright notice,
 *      this list of conditions and the following disclaimer.
 * 
 *  * Redistribution in binary form must reproduce the above copyright notice,
 *      this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 * 
 * Neither the name of Sun Microsystems, Inc. or the names of contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *  
 * This software is provided "AS IS," without a warranty of any kind. ALL
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN")
 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 *  
 * You acknowledge that this software is not designed, licensed or intended
 * for use in the design, construction, operation or maintenance of any
 * nuclear facility. 
 */

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class 
ListDemoMIDlet extends MIDlet {

    private 
Display              display;
    private 
int                  mode = List.IMPLICIT;

    private 
Command exitCommand = new Command"Exit",
                                   
Command.SCREEN);
    private 
Command selectCommand = new Command"Select",
                                       
Command.OK);
    private 
Command nextCommand = new Command"Next",
                                   
Command.SCREEN);
    public 
ListDemoMIDlet(){
    }

    protected 
void destroyAppboolean unconditional )
                   
throws MIDletStateChangeException {
        
exitMIDlet();
    }

    protected 
void pauseApp(){
    }

    protected 
void startApp() throws
    MIDletStateChangeException 
{
        if( 
display == null ){ // first time called...
            
initMIDlet();
        }
    }

    private 
void initMIDlet(){
        
display Display.getDisplaythis );
        
display.setCurrent( new SampleListmode ) );
    }

    public 
void exitMIDlet(){
        
notifyDestroyed();
    }

    public static final 
String[] items = {
        
"First""Second""Third""Fourth"
    
};


    class 
SampleList extends List implements
                           
CommandListener {

        private 
int mode;

        
SampleListint mode ){
            
super""modeitemsnull );
            
addCommandexitCommand );
            
addCommandselectCommand );
            
addCommandnextCommand );
            
setCommandListenerthis );

            switch( 
mode ){
                case 
IMPLICIT:
                    
setTitle"Implicit" );
                    break;
                case 
EXCLUSIVE:
                    
setTitle"Exclusive" );
                    break;
                case 
MULTIPLE:
                    
setTitle"Multiple" );
                    break;
            }

            
this.mode mode;
        }

        public 
void commandActionCommand c,
                             
Displayable d ){
            if( 
== exitCommand ){
                
exitMIDlet();
            } else if( 
== selectCommand ){
                
showSelectionfalse );
            } else if( 
== SELECT_COMMAND ){
                
showSelectiontrue );
            } else if( 
== nextCommand ){
                if( 
mode == List.IMPLICIT ){
                    
mode = List.EXCLUSIVE;
                } else if( 
mode == List.EXCLUSIVE ){
                    
mode = List.MULTIPLE;
                } else {
                    
mode = List.IMPLICIT;
                }

                
display.setCurrent( new SampleList(
                                             
mode ) );
            }
        }

        private 
void showSelectionboolean implicit ){
            
Alert alert = new Alert(
                       
implicit "Implicit Selection"
                               
"Explicit Selection" );
            
StringBuffer buf = new StringBuffer();

            if( 
mode == MULTIPLE ){
                
boolean[] selected = new booleansize() ];
                
getSelectedFlagsselected );

                for( 
int i 0selected.length; ++){
                    if( 
selected[i] ){
                        if( 
buf.length() == ){
                            
buf.append(
                             
"You selected: " );
                        } else {
                            
buf.append", " );
                        }

                        
buf.appendgetString) );
                    }
                }

                if( 
buf.length() == ){
                    
buf.append"No items are selected." );
                }
            } else {
                
buf.append"You selected " );
                
buf.appendgetString(
                       
getSelectedIndex() ) );
            }

            
alert.setStringbuf.toString() );
            
alert.setTimeoutAlert.FOREVER );

            
display.setCurrentalert,display.getCurrent() );
        }
    }
}
 

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 Handling m3g format (3D files for mobiles) in J2ME
 J2ME Image Capturing with Flash Light
 race game source code in j2me
 job offer for Senior J2me developer
 J2ME web cam view in my cell phone
 J2ME web cam view in my cell phone(may b bluetooth or ir)
 j2me io.File
 bluetooth in j2me
 j2me calender entry
 calendet j2me

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: Yahoo [Bot] and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team