Android coding guidelines
satya - 11/9/2013 9:04:08 AM
An activity header suggestion
/**
* Activity name: TestProgressBarDriverActivity
* Layout file: test_progressbar_activity_layout
* Layout shortcut prefix for ids: tpb_
* Menu file: tpb_menu.xml
*
*/
satya - 11/9/2013 9:13:30 AM
A more extensive activity doc
/**
* Stats
* ********************
* Activity name: TestProgressBarDriverActivity
* Layout file: test_progressbar_activity_layout
* Layout shortcut prefix for ids: tpb_
* Menu file: tpb_menu.xml
* Retained root object: AsyncTesterRADO
* Retained Fragment: AsyncTesterFragment
* Other fragments: None
* Configuration change: allowed, and covered
* Home and back: allowed, and covered
* Dialongs: none
* Asynctasks: yes, 1
*
*
* Primary goal:
* ***********************
* 1. To test a variety of progress bars
*
*/
satya - 11/9/2013 9:16:22 AM
One way to name the menu files and menu items
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This group uses the default category. -->
<group android:id="@+id/tpb_menuGroup_Main">
<item android:id="@+id/tpb_menu_test1"
android:title="Test Progress Bars" />
<item android:id="@+id/menu_clear"
android:title="clear" />
</group>
</menu>
satya - 11/9/2013 9:42:50 AM
You can do this using generics
public void startTargetActivity(Class<? extends Activity> targetActivityClass)
{
Intent i = new Intent(this,targetActivityClass);
startActivity(i);
}
//which simply allows you to do
SomeDerivedActivity act;
startTargetActivity(act);
//and prevents you from doing
SomeObject abc;
startTargetActivity(abc);
satya - 11/9/2013 9:45:41 AM
You can read my notes on java generics here
satya - 12/1/2013 10:34:30 AM
Here is how to document a layout file
<?xml version="1.0" encoding="utf-8"?>
<!--
*********************************************
* test_progressbar_activity_layout.xml
* prefix: tpb_
* Test a number of progress bars
* Controls:
* A series of progress bars
* followed by a text view
*********************************************
-->
satya - 12/1/2013 10:38:03 AM
A slightly better example perhaps
<?xml version="1.0" encoding="utf-8"?>
<!--
*********************************************
* calculator_layout.xml
* corresponding activity: CalculatorMainActivity.java
* prefix: cl_ (Used for prefixing unique identifiers)
*
* Use:
* Demonstrate a simple calculator
* Demonstrate text views, edit text, buttons, business logic
*********************************************
-->
satya - 12/2/2014, 11:44:11 AM
Another example
<?xml version="1.0" encoding="utf-8"?>
<!--
*********************************************
* test_loaders_activity_layout.xml
* corresponding activity: TestLoadersActicity.java
* prefix: tla_ (Used for prefixing unique identifiers)
*
* Use:
* Demonstrate loading a cursor using loaders
* Structure:
* Header message: text view (tla_header)
* ListView (fixed)
* Footer: text view (tla_footer)
* Empty View (To show when the list is empty): ProgressBar
************************************************
-->