JButton in GUI für Handys?

sirair

Aktives Mitglied
Hi,

erstelle für mein Telefon eine kleine GUI. Gibts die Möglichkeit ein JButton oder generell Buttons hinzuzufügen?
 
Zuletzt bearbeitet von einem Moderator:

The_S

Top Contributor
Du musst eine High-Level-GUI bauen. Da nimmste dann am besten ne Form und fügst ein StringItem mit dem Appearance-Mode BUTTON hinzu.
 

sirair

Aktives Mitglied
bei mir wird kein Button angezeigt. Woran liegts?
Java:
package Gui;


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

public class MainMidlet extends MIDlet implements CommandListener {

    private Display Display;
    private Form Form;
    private Command ExitCommand;

    public MainMidlet(){
        Display = Display.getDisplay(this);
        Form = new Form("test");
        StringItem Item = new StringItem("Item1", null, 2);
        StringItem Item2 = new StringItem("Item2", null, 2);
        Form.append(Item);
        Form.append(Item2);
        ExitCommand = new Command("Exit", Command.EXIT, 0);
        Form.addCommand(ExitCommand);
        Form.setCommandListener(this);
      
    }

    public void startApp() {
            
    mDisplay.setCurrent(Form);

    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if(c == ExitCommand){
            destroyApp(false);
            notifyDestroyed();
        }
    }
}
 

The_S

Top Contributor
Jop. Ist natürlich Geräteabhängig. Aber du solltest auf jeden Fall noch ein Command vom Typ Command.ITEM adden bzw. als DefaultCommand setzen

Java:
Item.setDefaultCommand(new Command("Test", "Test", Command.ITEM, 1));

Wenn du sicher gehen möchtest, würde ich dir eher zu normalen Command anstatt Buttons raten. Wenn du ein Menü simulieren möchtest, kannst du auch eine List mit normalen Einträgen nehmen. Dein StringItem könnte auch nur aus einem Bild bestehen, dass einen Button "simuliert". Oder du zeichnest dir gleich deinen eigenen Button mit einem CustomItem selbst.

Du siehst, in der Java ME Welt gibt es viele, aber fast keinen Standardweg ;) . Die Lösung hängt immer vom spezifischen Problem ab.

Noch eine generelle Anmerkung zu deinem Code:

Variablen und Attribute schreibt man klein.
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
Kazudemruzo Android API/Library für externe Entwickler zur Verfügung stellen Android & Cross-Platform Mobile Apps 7
C Consent für Admob mit ump / funding choices Android & Cross-Platform Mobile Apps 6
B Was fehlt mir hier für diese Klasse? ich habe es mit (>>> ... <<<) markiert. Android & Cross-Platform Mobile Apps 4
J SharedPreferences für User-Session Android & Cross-Platform Mobile Apps 2
M Barrierefreie Appentwicklung für Android - Suche Codebeispiele Android & Cross-Platform Mobile Apps 8
I App für Fire HD entwickeln Android & Cross-Platform Mobile Apps 3
T Bringen mir die Java-Basics irgendetwas für die Android-Programmierung Android & Cross-Platform Mobile Apps 4
L Textfeld für Dezimalzahl mit Vorzeichen Android & Cross-Platform Mobile Apps 2
J Android Datenbank Klasse nur für CRUD-Operation, oder auch mehr ? Android & Cross-Platform Mobile Apps 8
B Android Projekt für Android und IOS erstellen? Android & Cross-Platform Mobile Apps 5
J Impressumspflicht für App, wenn ich kein Unternehmer bin? Android & Cross-Platform Mobile Apps 13
T Android Equalizer für Android Android & Cross-Platform Mobile Apps 3
L Zeitstempel für Sensordaten bekommen Android & Cross-Platform Mobile Apps 3
L Android Texterkennung für Android? Android & Cross-Platform Mobile Apps 1
L Android Chart API für Android Android & Cross-Platform Mobile Apps 0
T Android Datenbankverbindung in Service für Push Notification Android & Cross-Platform Mobile Apps 0
R Android USB Treiber für Huawei Android & Cross-Platform Mobile Apps 1
M Hilfe bei App Programmierung für Android Android & Cross-Platform Mobile Apps 1
B Script für Android Android & Cross-Platform Mobile Apps 1
H Datenprotokoll für Graphview Android & Cross-Platform Mobile Apps 2
M Android Obfuscation für Strings Android & Cross-Platform Mobile Apps 8
S Bilder mit fester grösse für verschiedene Android Endgeräte Android & Cross-Platform Mobile Apps 2
D Android Layout für alle Geräte Android & Cross-Platform Mobile Apps 4
A String[] für Lisadapter Android & Cross-Platform Mobile Apps 4
D Lib für (Desktop-)Java und Android schreiben Android & Cross-Platform Mobile Apps 7
J MySQL Simulation für Android App Android & Cross-Platform Mobile Apps 2
kaoZ Tutorial .xml Layouting für z.B ListView elemente Android & Cross-Platform Mobile Apps 7
W Java Editor für Android +Emulator Android & Cross-Platform Mobile Apps 7
M 20 Image Button für jede Auflösung positionieren Android & Cross-Platform Mobile Apps 3
L Android ActionBar mit unterschiedlichen Farben für Tabs Android & Cross-Platform Mobile Apps 3
S Voraussetzungen für Android-Apps Android & Cross-Platform Mobile Apps 7
R Sinnvoller Ablageort für Leveldaten Android & Cross-Platform Mobile Apps 8
B App bei Play-Store für bestimmte auflösungen anbieten? Android & Cross-Platform Mobile Apps 3
G extends Activity für Berechnungen? Android & Cross-Platform Mobile Apps 7
H Progrämmchen für Symbian Android & Cross-Platform Mobile Apps 4
G wiederkehrenden Wert für Design in XML ablegen Android & Cross-Platform Mobile Apps 2
L Android SearchBox für Custom Listview Android & Cross-Platform Mobile Apps 5
T Android KontrollApp für Nitrado Server Android & Cross-Platform Mobile Apps 2
L Android Eine Kleinigkeit für Profis Android & Cross-Platform Mobile Apps 2
G Android C++ Quellcode für Android Geräte compilieren Android & Cross-Platform Mobile Apps 2
T Zeit in zwei Zahlen für Widget zerlegen Android & Cross-Platform Mobile Apps 2
J Apps für Android programmieren - Android Handy notwendig oder reicht Simulator? Android & Cross-Platform Mobile Apps 3
A Android SimpleDateFormat gibt für Date unter android anderes Datum zurück als in Std. Java Android & Cross-Platform Mobile Apps 2
H Android Landscape Modus für App dektivieren Android & Cross-Platform Mobile Apps 3
M Frage zu Java Programm für Windows Mobile 6.5 Android & Cross-Platform Mobile Apps 2
H Welches JDK für Huawei G7002? Android & Cross-Platform Mobile Apps 6
C Panel/View für Android Android & Cross-Platform Mobile Apps 3
C Sanke für Android Android & Cross-Platform Mobile Apps 3
Kukulkan Welche Mindestanforderungen (JDK) für Android und BB? Android & Cross-Platform Mobile Apps 8
G Views für verschiedenen Bildschirmgroeßen Android & Cross-Platform Mobile Apps 2
thE_29 Widget für verpasste Anruf + SMS Android & Cross-Platform Mobile Apps 2
A Android Android Parameter für VM Android & Cross-Platform Mobile Apps 7
O Entwickler für Java Anwendungen auf Handy gesucht! Android & Cross-Platform Mobile Apps 3
M Welche Datenbank für J2ME? Android & Cross-Platform Mobile Apps 5
D Event für Tastensperre? Android & Cross-Platform Mobile Apps 3
G WTK für Nokia Android & Cross-Platform Mobile Apps 2
P bestimmte API für XDA ORBIT2 Android & Cross-Platform Mobile Apps 3
S Idee gesucht für ein kleines Programm Android & Cross-Platform Mobile Apps 3
M ein image pixel für pixel aufbauen : setPixel() ? Android & Cross-Platform Mobile Apps 1
M Handyprogramm für U-Bahn-Fahrplan für Siemens SK65 Android & Cross-Platform Mobile Apps 2
J Empfehlungen für ME-Anfänger Android & Cross-Platform Mobile Apps 2
K Anwendung für Handy programmieren Android & Cross-Platform Mobile Apps 1
P Java für PDA DELL Axim 51 Android & Cross-Platform Mobile Apps 4
M Virtuelle Machiene für PDA Android & Cross-Platform Mobile Apps 8
B Programm für NokiaComunicator erstellen Android & Cross-Platform Mobile Apps 2
K Programme für Handy erstellen Android & Cross-Platform Mobile Apps 3
M Java-Programme für Handy auf Desktop-PC ausführen Android & Cross-Platform Mobile Apps 4
T Für Handy Game die Sprache umschreiben? Android & Cross-Platform Mobile Apps 24
M java game für handy mit grahi. oberfläche Android & Cross-Platform Mobile Apps 1
D java.security.MessageDigest (für ME?) Android & Cross-Platform Mobile Apps 1
N Unser Team such Coder für Spieleprojekte Android & Cross-Platform Mobile Apps 8
B WTK für Sony Ericsson? Android & Cross-Platform Mobile Apps 7
S JAVA für java-mobiltelefone Android & Cross-Platform Mobile Apps 14
M Android Kabellose Datenübertragung zwischen zwei Handys - Reichweiten Android & Cross-Platform Mobile Apps 3
B Mit Button GeräteEinstellung des Handys öffnen Android & Cross-Platform Mobile Apps 3
F Touch-Handys Android & Cross-Platform Mobile Apps 8
Bastifantasti Lagesensor eines Handys ansprechen? Android & Cross-Platform Mobile Apps 48
R Java Programmierung auf Handys Android & Cross-Platform Mobile Apps 8
I SMS - geeignete Handys Android & Cross-Platform Mobile Apps 4
O Bluetooth Verbindung zwischen 2 Handys Android & Cross-Platform Mobile Apps 5
M java in handys Android & Cross-Platform Mobile Apps 1

Ähnliche Java Themen

Neue Themen


Oben