Use Listview and ListPicker

Now we will try another component from app inventor 2. There are listview and listpicker. Listview is like combo box in J2SE or spinner in app inventor 2. the function of listview is like spinner but it is not open another screen, it just in the same screen. if you want to catch a value from listview, you can get and view that in label. Different with spinner, spinner’s action can make basic interface is lock after the spinner is choose. About listpicker, when listpicker is click, there is a value that can be choosed in listpicker‘s screen. After choosed value, it will return to first listpicker button, and the value will be filled in that listpicker button. Here the example :

This slideshow requires JavaScript.

Here the block code :

  1. ListView

  2. ListPicker

    ListPicker Block


    Final Block ListPicker

  3. Slider

    Slider Block


    Final Slider Block

Try Spinner in app inventor 2

now, in this page… we will talk about spinner. in java dekstop (J2SE), spinner like combo box, the value answer can be choosed. After choose the answer, the value will be catched in the variable of spinner. In the previous page, we talk about if condition, the preview shows a view component especially spinner. so, in this page, we will view again that image to reader and add a new information properties of spinner. here the preview :


in the right side of screen1, there is a component’s widget that fill an structure of component and a spinner componen can view a properties if you click the spinner’s component (it shows in properties’s widget). The spinner value can fill in the “ElementsFromString” textfield. The value must be spaced with coma. In “Prompt” fill, it just give an information of spinner like header name of spinner.


Result in emulator :


Here the “Block” code :


App Inventor 2 : If Condition

if condition usually use to compare two or more answer that are suitable or not. this condition produces an answer true or false value.  for an example :


here the example block code for if condition:


In emulator there is a spinner for choose a status, here the block code combine with if condition :


Model Class System.out.print in Android

In java, if we want to print a value from variable or other process, we can use System.out.print() or System.out.println(). it’s always work in java, but when it try in android program, we can’t find it or System.out.print maybe can’t use in android. Android already give an alternative syntax for handle System.out.print from java, is Log class. Log class is coming from android.util.Log, That’s a reference library for use or take a Log class syntax.

Here an example : 

package com.apps.helloworld;

import android.os.Bundle;
import android.provider.Settings.System;
import android.content.DialogInterface;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {

private EditText txtInggris;
private EditText txtIndonesia;
private EditText txtJerman;
public static final String INGGRIS = “Inggris”;
public static final String INDONESIA = “Indonesia”;
public static final String JERMAN = “Jerman”;
private Button btn;
private TextView tv;
AlertDialog al;

protected void onCreate(Bundle savedInstanceState) {

txtInggris = (EditText)findViewById(;
tv = (TextView)findViewById(;
btn = (Button)findViewById(;
al = new AlertDialog.Builder(this).create();

btn.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub

Log.d(“T”, “test”);
Log.i(“T”, “test lg”);
al.setButton(“Ok aja”, new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub


public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(, menu);
return true;


So, The result from the code will be showed in LogCat.

Here the result :

Result LogCat

Result LogCat

Deep Mind About Android

when we want to create an android project, firstly we must know structure a basic android program. it’s not much different from structure java program, it’s still use java concept. When we want use a method in android, it’s same when you create method in java. ex : public void test(), also with variable. Variable is container for temporary data who can use in object or class, but you must know when variable call with object and call with class, very different. Ok… now continue to create structure of android program :

android program

Structure Android Program