[SOLVED] 程序代写 CS 213 SOFTWARE METHODOLOGY

30 $

File Name: 程序代写_CS_213_SOFTWARE_METHODOLOGY.zip
File Size: 376.8 KB

SKU: 5665339836 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


CS 213 SOFTWARE METHODOLOGY
LILY CHANG ASSOCIATE TEACHING PROFESSOR DEPARTMENT OF COMPUTER SCIENCE RUTGERS UNIVERSITY – NEW BRUNSWICK FALL 2021

Android UI Components

Copyright By PowCoder代写加微信 assignmentchef

Android Views
•Every visible component on the screen is a View
•The View class represents the basic building block for user interface components, and the base class for classes that provide interactive UI components such as buttons, checkboxes, and text entry fields
• A View occupies a rectangular area on the screen and is responsible for drawing and event handling.
•A View has a location, expressed as a pair of left and top coordinates, and two dimensions, expressed as a width and a height. The unit for location and dimensions is the density- independent pixel (dp)
•All of the views in a window are arranged in a single tree. You can add views either from code or by specifying a tree of views in one or more XML layout files.

Android Views Relevant to Project 5
EditText / TextInputLayout
Button / ImageButton, onClick()
ImageView, onClick()
RadioButton
RadioGroup

•A user interface element that displays text to the user
android:layout_height=”wrap_content”
android:layout_width=”wrap_content”

1. match_constraint – as big as its parent (minus padding)
2. wrap_content – just big enough to enclose its content (plus padding).
3. exact values

•A user interface element for entering and modifying text.
•When you define an edit text widget, you must specify the R.styleable.TextView_inputType attribute. •For example, for plain text input set inputType to “text”:
•Choosing the input type configures the keyboard type that is shown, acceptable characters, and appearance of the edit text.
•For example, if you want to accept a secret number, like a unique pin or serial number, you can set inputType to “numericPassword”
orderlist = new ArrayAdapter (this, android.R.layout.simple_list_item_1, itemList);
ListView orders;
… order.setAdapter(orderlist);
context resource data source

Spinner Class
•A view that displays one child at a time and lets the user pick among them
•The items in the Spinner come from the Adapter associated with this view
•Spinner is a subclass of the abstract class AdapterView
•If you define the data set with an array, use the ArrayAdapter
•Could also set the initial data items with the attribute “entries” in the layout editor
•The simple_spinner_item layout and the simple_spinner_dropdown_item layout are the default predefined layouts provided by Android in the R.layout class.
ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.dataArray,
android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dro pdown_item);
mySpinner.setAdapter(adapter);

Spinner class Listener and Event-Handler
• Spinner class inherits the abstract class AdapterView, which is a view whose children are determined by an Adapter
• When the user selects an item in the Spinner, the Spinner receives an on-item-selected event.
• In order to handle the selection, you must implement the Interface OnItemSelectedListner and override the 2 methods below and call the setOnItemSelectedListener(this) method; for example,
public class OrderActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener { } private Spinner spinner;
protected void onCreate(Bundle savedInstanceState) {
spinner = findViewById(R.id.mySpinner);
spinner.setOnItemSelectedListener(this);
public void onItemSelected(AdapterViewparent, View view, int position, long id) { } @Override
public void onNothingSelected(AdapterViewparent) { } //can leave it empty

Spinner Class
public void onItemSelected(AdapterViewparent, View view, int position, long id) { }
•Useful public methods to use given an instance of Spinner with the listener defined
• getSelectedItemPosition() • getSelectedItem()
• getSelectedItemId()
• getSelectedView()

ListView class
•Displays a vertically-scrollable collection of views, where each view is positioned immediately below the previous view in the list
•ListView class inherits the abstract class AdapterView (same as the Spinner class)
• Set the data items with the AdapterView (refer to the Spinner class slide), or with the
attribute “entries” in the layout editor
•When the user selects an item in the ListView, the ListView receives an on-item-click event
•In order to handle the selection, you must implement the Interface OnItemClickListner and implement the onItemClick method and call the setOnItemClickListener(this) method.

public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener private ListView listview;
protected void onCreate(Bundle savedInstanceState) {
listview = findViewById(R.id.myListview);
listview.setOnItemClickListener(this);
ArrayAdapter list = new ArrayAdapter (this, android.R.layout.simple_list_item_1, itemList); listview.setAdapter(list);
public void onItemClick(AdapterViewparent, View view, int position, long id) { }

Activity Class
AndroidManifest.xml
Each activity has a .java file and a .xml file; for example,
The .xml file is where you create the UI components
Register the activities in your app
Define the Intent Filter
• Explict intent • Implict intent
MainActivity.javaà activity_main.xml
SecondActivity.javaà activity_second.xml
Use the Android Layout Editor
Write the xml code directly

Adding an Activity in AndroidManifest.xml

SecondActivity.java

define the back button
Title of the activity
A constant String value

Intent Object Revisited
Intent intent = new Intent(this, SignInActivity.class);
startActivity(intent);
•The Intent object specifies either the exact activity you want to start or describes the type of action you want to perform (and the system selects the appropriate activity for you, which can even be from a different application).
•An Intent object can also carry small amounts of data to be used by the activity that is started.

Intent Class/Object
•The primary pieces of information in an intent are: • action – The general action to be performed, such as
ACTION_VIEW, ACTION_EDIT, ACTION_MAIN, etc.
• data – the data to operate on, such as a person record in the contacts database, expressed as a Uri.
•For example,
ACTION_VIEW content://contacts/people/1
• Display information about the person whose identifier is ”1″.

Intent Extra
Sharing data between different activities
This is a Bundle of any additional information. This can be used to provide extended
information to the component.
For example, if we have an action to send an e- mail message, we could also include extra pieces of data here to supply a subject, body, etc.

Sharing Data with Extra Data –Example
public Intent putExtra (String name, Bundle value)
• name – String: the name of the extra data; used as a key to retrieve the value. • value – Bundle: the Bundle data value; this value may be null.
//in FirstActivity
public static final String EXTRA_MESSAGE = “com.example.android.twoactivities.extra.MESSAGE”;
String message = …..;
intent.putExtra(EXTRA_MESSAGE, message);
value ould be String, primitive types or class types that implement Serializable or Parcelable
The name of the key. By convention, use the Package prefix so it is unique
//in SecondActivity
Intent intent = getIntent();
String message = intent.getStringExtra(FirstActivity.EXTRA_MESSAGE); //retrieve the value with the “key”

Intent Extra – Integer type
//in FirstAtivity
int size = 10;
Intent intent = new Intent(this, SecondActivity.class); intent.putExtra(“MAXSIZE”, size); //key name is MAXSIZE, value is size
//in SecondActivity
Intent intent = getIntent();
int size = intent.getIntExtra(“MAXSIZE”, 0);
default value if the extra data is not available for some reason.

Intent Extra – Class type
•For the object you wanted to share among activities, the class type must implement either Serializable Interface or Parcelable Interface
•Serialization method; the class type must implement the Serializable Interface //FirstActivity
Intent intent = new Intent(this, SecondActivity.class);
intent.putExtra(”ORDER”, order); //where order is an instance of Order class that is serialized startActivity(intent);
//SecondActivity
Intent intent = getIntent();
Order order = (Order) intent.getSerializableExtra(”ORDER”); //retrieve and deserialize the extra data

Intent Extra – Parcel
•Part of the Android SDK
•Preferred method for sharing objects between activities
•Class type must implement Parcelable Interface to send the “parcel” object
•See the Adroid API reference for implementation https://developer.android.com/reference/android/os/Parcelable
•Use the follow method to get the parcel object in the SecondActivity public T getParcelableExtra (String name)

Example – Parcelable
//FirstActivity
intent.putExtra(”ORDER”, order);
//SecondActivity
Intent intent = getIntent();
Order order = intent.getParcelableExtra(”ORDER”);

What is Gradle?
•Gradle is an open-source build automation tool that is designed to be flexible enough to build almost any type of software
• Avoids unnecessary work by only running the tasks that need to run because their inputs or outputs have changed
• Runs on the JVM and you must have a Java Development Kit (JDK) installed to use it.
• You can readily extend Gradle to provide your own task types or even build model
• Build scans provide extensive information about a build run that you can use to identify build issues.

app/build.gradle

What are dependency configurations?
•Every dependency declared for a Gradle project applies to a specific scope.
•For example, some dependencies should be used for compiling source code whereas others only need to be available at runtime.
•Gradle represents the scope of a dependency with the help of a Configuration. Every configuration can be identified by a unique name
•Module dependencies, File dependencies, Project dependencies

Material Design UI Components
•Make sure you include the material design dependencies in build.gradle

程序代写 CS代考加微信: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 程序代写 CS 213 SOFTWARE METHODOLOGY
30 $