Android POCs (Proof of Concepts)

ButtonPress-LabelShow

This little app has a Button and TextView in layout file main.xml. A listener is set to the button1 to call a method to display a string to textView1.

download  or   install to your Android





ButtonPress-LabelShow/src/com/brainyideas/dev/bpls/BPLS.java
package com.brainyideas.dev.bpls;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class BPLS extends Activity {
	
    Button button1;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        
    	super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        init();
    }
    
    void init() {
    	
        button1 = (Button) findViewById(R.id.button1);
        button1.setOnClickListener(new OnClickListener() {

            public void onClick(final View v) {
                labelShow();
            }
        });
    }
    
    void labelShow() {
    	
    	TextView log = (TextView) findViewById(R.id.textView1);
    	log.setText("Present at 11:30am");
    }
}

ButtonPress-LabelShow/res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<TextView android:text="@string/startvalue" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

</LinearLayout>

ButtonPress-LabelShow/res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">BPLS</string>
    <string name="startvalue">PressMe</string>
</resources>