Professional Documents
Culture Documents
Ian Bayley
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
Lecture Overview I
1
Adding a Menu to Hello World How to program menus The le src\...\HelloWorldMenu.java Adding an Intent to Hello World How to use intents to create a subactivity The le src\...\HelloWorldIntent.java The le src\...\HelloWorldIntentSub.java The le AndroidManifest.xml How to use intents to communicate with that subactivity Adding a responsive ListView and EditText to Hello World What we need to do The le res\layout\main.xml The le src\...\HelloWorldListView.java
Ian Bayley Programming Mobile Phones
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
Ian Bayley
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
Activity method onCreateOptionsMenu Menu method add to give it a label and id 0,1,2
two dummy arguments
...
groupId
order
context menus are similar Simplest app that has a menu show the id for each menu item as a toast
Ian Bayley Programming Mobile Phones
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
Ian Bayley
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
How to use intents to create a subactivity The le src\...\HelloWorldIntent.java The le src\...\HelloWorldIntentSub.java The le AndroidManifest.xml How to use intents to communicate with that subactivity
Ian Bayley
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
How to use intents to create a subactivity The le src\...\HelloWorldIntent.java The le src\...\HelloWorldIntentSub.java The le AndroidManifest.xml How to use intents to communicate with that subactivity
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
How to use intents to create a subactivity The le src\...\HelloWorldIntent.java The le src\...\HelloWorldIntentSub.java The le AndroidManifest.xml How to use intents to communicate with that subactivity
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
How to use intents to create a subactivity The le src\...\HelloWorldIntent.java The le src\...\HelloWorldIntentSub.java The le AndroidManifest.xml How to use intents to communicate with that subactivity
} });
startActivity(intent);
Ian Bayley
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
How to use intents to create a subactivity The le src\...\HelloWorldIntent.java The le src\...\HelloWorldIntentSub.java The le AndroidManifest.xml How to use intents to communicate with that subactivity
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
How to use intents to create a subactivity The le src\...\HelloWorldIntent.java The le src\...\HelloWorldIntentSub.java The le AndroidManifest.xml How to use intents to communicate with that subactivity
Ian Bayley
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
How to use intents to create a subactivity The le src\...\HelloWorldIntent.java The le src\...\HelloWorldIntentSub.java The le AndroidManifest.xml How to use intents to communicate with that subactivity
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
How to use intents to create a subactivity The le src\...\HelloWorldIntent.java The le src\...\HelloWorldIntentSub.java The le AndroidManifest.xml How to use intents to communicate with that subactivity
/>
<category android:name= "android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".HelloWorldIntentSub" android:label="@string/app_name2"> </activity> </application> </manifest>
Ian Bayley
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
How to use intents to create a subactivity The le src\...\HelloWorldIntent.java The le src\...\HelloWorldIntentSub.java The le AndroidManifest.xml How to use intents to communicate with that subactivity
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
Ian Bayley
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
What we need to do
add an unresponsive list view add a list to an adapter and add the adapter to the list view
an adapter makes a view for each item in the list one parameter supplies a layout for this
1 2
4 5
Ian Bayley
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ListView android:id="@+id/listView" android:layout_height="wrap_content" android:layout_width="fill_parent"> </ListView> <EditText android:layout_width="fill_parent" android:layout_height="wrap_content"
Ian Bayley Programming Mobile Phones
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
Ian Bayley
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
} ); editText.setOnKeyListener(new OnKeyListener(){ @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() ==
Ian Bayley Programming Mobile Phones
Adding a Menu to Hello World Adding an Intent to Hello World Adding a responsive ListView and EditText to Hello World
} });
Ian Bayley