|     Inicio    |   |         |  |   FOROS      |  |      |      
   Elastix - VoIP B4A (Basic4Android) App inventor 2 PHP - MySQL
  Estación meteorológica B4J (Basic4Java) ADB Shell - Android Arduino
  AutoIt (Programación) Visual Basic Script (VBS) FireBase (BD autoactualizable) NodeMCU como Arduino
  Teleco - Emisora de A.M. Visual Basic Cosas de Windows Webs interesantes
T Búsqueda en este sitio:


.

App inventor 2 en español
Cómo programar los teléfonos móviles con Android.
Curso de App inventor 2 en español - Juan Antonio Villalpando

-- Tutorial de iniciación de App Inventor 2 en español --

Volver al índice del tutorial

_________________________________________________
118.- Java Bridge. VisorDeLista. Notificador. Archivo. TinyDB. MiniWebDB.

- VisorDeLista: funciona.

- Notificador: funciona.

- Archivo: funciona.

- TinyDB: no funciona. Lee valor, pero no deja escribirlo.

- MiniWebDB: no crea el archivo java. No funciona.

_____________________________________________________

VisorDeLista.aia

_____________________________________________________
- Diseño.

_____________________________________________________
- Bloques.

 

_____________________________________________________
- Conversion a Java.

- Pulsamos en "Generate Java"

- Pulsamos en JAVA FILE.

Screen1.java
			  
package juan.com.visordelista; // Cambia por tu package.
import com.google.appinventor.components.runtime.HandlesEventDispatching;
import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.runtime.Form;
import com.google.appinventor.components.runtime.Component;
import com.google.appinventor.components.runtime.ListView;
import com.google.appinventor.components.runtime.Label;
import com.google.appinventor.components.runtime.Notifier;
import com.google.appinventor.components.runtime.File;
import com.google.appinventor.components.runtime.TinyDB;
class Screen1 extends Form implements HandlesEventDispatching {
    private ListView VisorDeLista1;
    private Label Etiqueta1;
    private Notifier Notificador1;
    private File Archivo1;
    private TinyDB TinyBD1;
    protected void $define() {
        this.AppName("VisorDeLista2");
        this.Title("VisorDeLista - Juan A. Villalpando");
        VisorDeLista1 = new ListView(this);
        VisorDeLista1.ElementsFromString("Notificador, Archivo Escribir, Archivo Leer, TinyDB Escribir, TinyDB Leer");
        Etiqueta1 = new Label(this);
        Etiqueta1.FontBold(true);
        Etiqueta1.FontSize(22);
        Etiqueta1.Text("Texto para Etiqueta1");
        Etiqueta1.TextColor(0xFF0000FF);
        Notificador1 = new Notifier(this);
        Archivo1 = new File(this);
        TinyBD1 = new TinyDB(this);
        EventDispatcher.registerEventForDelegation(this, "AfterPickingEvent", "AfterPicking" );
        EventDispatcher.registerEventForDelegation(this, "GotTextEvent", "GotText" );
    }
    public boolean dispatchEvent(Component component, String componentName, String eventName, Object[] params){
        if( component.equals(VisorDeLista1) && eventName.equals("AfterPicking") ){
            VisorDeLista1AfterPicking();
            return true;
        }
        if( component.equals(Archivo1) && eventName.equals("GotText") ){
            Archivo1GotText((String)params[0]);
            return true;
        }
        return false;
    }
    public void VisorDeLista1AfterPicking(){
        if(VisorDeLista1.SelectionIndex()==1){
            Notificador1.ShowAlert("Ejemplo de Notificador."); // Manual
        }
        if(VisorDeLista1.SelectionIndex()==2){
            Archivo1.AppendToFile("Esto es texto.", "prueba.txt");
        }
        if(VisorDeLista1.SelectionIndex()==3){
            Archivo1.ReadFrom("prueba.txt");
        }
        if(VisorDeLista1.SelectionIndex()==4){
            TinyBD1.StoreValue("valor", "12345");
        }
        if(VisorDeLista1.SelectionIndex()==5){
            Etiqueta1.Text(String.valueOf(TinyBD1.GetValue("valor", "valor")));
        }
    }
    public void Archivo1GotText(String texto){
        Etiqueta1.Text(texto);
    }
}

_____________________________________________________

__________________________________

- Mi correo:
juana1991@yahoo.com
- KIO4.COM - Política de cookies. Textos e imágenes propiedad del autor:
© Juan A. Villalpando
No se permite la copia de información ni imágenes.
Usamos cookies propias y de terceros que entre otras cosas recogen datos sobre sus hábitos de navegación y realizan análisis de uso de nuestro sitio.
Si continúa navegando consideramos que acepta su uso. Acepto    Más información