Download presentation
Presentation is loading. Please wait.
Published byAmanda Dalton Modified over 8 years ago
1
COMP 365 Android Development
2
Developing for Android XML for user interface formatting and other scripting Java for programming
3
XML is a markup language Uses tags to contain data like so data Can close tags without using data like so Can contain attributes Can nest tags within each other
4
main_activity.xml under res-> layout in Eclipse to change the XML Change the layout by changing the first tag LinearLayout RelativeLayout WebView Attributes for layout android:layout_width android:orientation
5
EditText Add within the layout tag Attributes android:layout_width & android:layout_height android:id Adding a string to display in the textbox Res → values → string in Ecplise text
6
Under res → layout Button Attributes android:text Link to the string resource android:text = “@string/resource-name”
7
Adding an onClick event to the button Attribute – android:onClick=”functionName” FunctionName has a View object as a parameter, and returns void
8
When the onClick event activates, bring up an Alert Dialog //Create a new Dialog AlertDialog.Builder alert = new AlertDialog.Builder( this ); //Get a reference to the EditText field EditText userInput = (EditText)findViewById(R.id.edit_message); //Get the text from the EditText field String message = userInput.getText().toString(); //Name of the Dialog alert.setTitle(“User input is:”); //Name of the message alert.setMessage( message ); //Give the Dialog an “Ok” button, not necessary though alert.setPositiveButton(“Ok”, null); //show the dialog alert.show();
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.