TextView
satya - Sunday, October 12, 2008 9:07:45 AM
sample xml
<TextView 
   android:id="@+id/text1"
   android:layout_width="fill_parent" 
   android:layout_height="wrap_content" 
   android:text="@string/hello"
   android:capitalize="sentences"
/>
satya - Sunday, October 12, 2008 9:08:46 AM
Button sample xml
<Button 
   android:id="@+id/b1"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@+string/hello"
/>
satya - Sunday, October 12, 2008 9:37:08 AM
Using a button in java
private void setupButton()
{
   Button b = (Button)this.findViewById(R.id.button1);
   b.setOnClickListener(
         new Button.OnClickListener(){
            public void onClick(View v)
            {
               parentButtonClicked(v);
            }
         });
   
}
private void parentButtonClicked(View v)
{
   this.appendText("\nbutton clicked");
   this.dial();
}
satya - Sunday, October 12, 2008 9:42:30 AM
Using EditText
<EditText
   android:id="@+id/editText1"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="Enter Text(prompt:)"
/>
satya - Monday, October 13, 2008 9:22:06 AM
android regular expression validators
android regular expression validators
satya - Monday, October 13, 2008 9:29:13 AM
Another very nice link on expressions
satya - Monday, October 13, 2008 9:42:43 AM
Telephone uri standards document
satya - Monday, October 13, 2008 9:46:35 AM
An important package to understand phone number formats
satya - Monday, October 13, 2008 1:39:39 PM
You will need to know the DialogInterface
satya - Tuesday, October 14, 2008 11:21:14 AM
Here is a nice layout for name/password like dialog
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <TextView 
        android:id="@+id/username_view"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_marginLeft="20dip"
        android:layout_marginRight="20dip"
        android:text="@string/alert_dialog_username"
        android:gravity="left"
        android:textAppearance="?android:attr/textAppearanceMedium" />
            
    <EditText
        android:id="@+id/username_edit"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_marginLeft="20dip"
        android:layout_marginRight="20dip"
        android:scrollHorizontally="true"
        android:autoText="false"
        android:capitalize="none"
        android:gravity="fill_horizontal"
        android:textAppearance="?android:attr/textAppearanceMedium" />
    <TextView
        android:id="@+id/password_view"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_marginLeft="20dip"
        android:layout_marginRight="20dip"
        android:text="@string/alert_dialog_password"
        android:gravity="left"
        android:textAppearance="?android:attr/textAppearanceMedium" />
            
    <EditText
        android:id="@+id/password_edit"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_marginLeft="20dip"
        android:layout_marginRight="20dip"
        android:scrollHorizontally="true"
        android:autoText="false"
        android:capitalize="none"
        android:gravity="fill_horizontal"
        android:password="true"
        android:textAppearance="?android:attr/textAppearanceMedium" />
        
</LinearLayout>
satya - Tuesday, October 14, 2008 1:35:41 PM
Problem with call back
public class PromptListener 
implements android.content.DialogInterface.OnClickListener
{
   public String promptValue = null;
   public void onClick(DialogInterface v, int buttonId)
   {
      promptValue="hello";
   }
}
public static String Prompt(String message, Context ctx)
{
   //load some kind of a view
   LayoutInflater li = LayoutInflater.from(ctx);
   View view = li.inflate(R.layout.promptdialog, null);
   
   //get a builder and set the view
   AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
   builder.setTitle("Prompt");
   builder.setView(view);
   
   //add buttons and listener
   PromptListener pl = new PromptListener(view,ctx);
   builder.setPositiveButton("OK", pl);
   builder.setNegativeButton("Cancel", pl);
   
   //get the dialog
   AlertDialog ad = builder.create();
   
   //show
   ad.show();
   
   //How come the following is "null" ???
   //when it shoudl be "hello" on a button click
   return pl.prompt;
}
satya - Tuesday, October 14, 2008 4:36:58 PM
A discussion on modal dialogs
satya - Friday, December 05, 2008 11:08:57 AM
A simple activity
public class FrameAnimationActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.frame_animations_layout);
    }
}//eof-class
satya - Friday, December 05, 2008 11:21:39 AM
Example of an imageview
<ImageView
        android:id="@+id/animationImage"
        android:scaleType="fitCenter"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:visibility="gone" />
satya - Friday, December 05, 2008 11:27:41 AM
Declaring an activity in the manisfest file
<activity android:name=".frameanimation.FrameAnimationActivity"
            android:label="Frame Animation Test">
</activity>
satya - Friday, December 05, 2008 11:28:03 AM
A simple sample manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.ai.android.HelloWorld"
      android:versionCode="1"
      android:versionName="1.0.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".HelloWorld"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".animation.Transition3d"
                  android:label="@string/app_name">
        </activity>
        <activity android:name=".frameanimation.FrameAnimationActivity"
                  android:label="Frame Animation Test">
        </activity>
    </application>
</manifest>
satya - Friday, December 05, 2008 11:30:59 AM
Two ways of invoking an activity
public static void invokeAnimActivity(Activity inActivity)
	{
		Intent intent = new Intent(inActivity,Transition3d.class);
		inActivity.startActivity(intent);
	}
	public static void invokeAnimActivity1(Activity inActivity)
	{
		Intent intent = new Intent();
		ComponentName cn = new ComponentName("com.ai.android.HelloWorld"
				,"com.ai.android.HelloWorld.animation.Transition3d");
		intent.setComponent(cn);
		inActivity.startActivity(intent);
	}
satya - Friday, December 05, 2008 11:31:59 AM
The easier of the two
public static void invokeFrameAnimActivity(Activity inActivity)
{
  Intent intent = new Intent(inActivity,FrameAnimationActivity.class);
  inActivity.startActivity(intent);
}
satya - Tuesday, April 21, 2009 9:11:04 AM
A simple menu
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- This group uses the default category. -->
    <group android:id="@+id/menuGroup_Main">
    
        <item android:id="@+id/OpenGL10_activity"
            android:orderInCategory="1"
            android:title="10 Simple Triangle" />
            
        <item android:id="@+id/OpenGL15_activity"
            android:orderInCategory="2"
            android:title="15 Simple Triangle" />
            
        <item android:id="@+id/menu_clear"
            android:orderInCategory="10"
            android:title="clear" />
    </group>
</menu>
satya - Tuesday, April 21, 2009 9:14:47 AM
A simple non xml menu usage
@Override
    public boolean onCreateOptionsMenu(Menu menu) 
    {
    	//call the parent to attach any system level menus
    	super.onCreateOptionsMenu(menu);
    	int base=Menu.FIRST; // value is 1
    	menu.add(base,base,base,"Test OpenGL");
    	return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) 
    {
    	if (item.getItemId() == Menu.FIRST)
    	{
    		Intent intent = new Intent(this,OpenGLTestHarnessActivity.class);
    		startActivity(intent);
        	return true;
    	}
    	return super.onOptionsItemSelected(item);
    }
satya - Tuesday, April 21, 2009 9:16:27 AM
Inflating an xml menu
@Override
    public boolean onCreateOptionsMenu(Menu menu) 
    {
    	//call the parent to attach any system level menus
    	super.onCreateOptionsMenu(menu);
   	MenuInflater inflater = getMenuInflater(); //from activity
   	inflater.inflate(R.menu.main_menu, menu);
    	return true;
    }
satya - Tuesday, April 21, 2009 9:20:28 AM
Here is how you respond to
@Override
    public boolean onOptionsItemSelected(MenuItem item) 
    {
    	if (item.getItemId() == R.id.OpenGL10_activity)
    	{
  		this.invoke10SimpleTriangle();
        	return true;
    	}
    	if (item.getItemId() == R.id.OpenGL15_activity)
    	{
    		this.invoke15SimpleTriangle();
        	return true;
    	}
    	return super.onOptionsItemSelected(item);
    }
satya - Tuesday, April 21, 2009 9:50:23 AM
how to see debug messages: logcat
window/
show view/
other/
android/
logcat