https://github.com/danapaduraru/AndroidLabs/commit/3fc593f5a46d8113c7b06977a9feefff6bdb57b2
https://github.com/danapaduraru/AndroidLabs/commit/b16eb46e87897b87b20857e434a5124afe3a3fe6
Implement functionalities for the menu you created in Lab 3 (2p)
|
/* LAB 4 */ |
|
|
|
/* Implement functionalities for the menu you created in Lab 3 (2p) */ |
|
|
|
@Override |
|
public boolean onOptionsItemSelected(MenuItem menuItem) { |
|
// respond to menu item selection |
|
String menuMsg = ""; |
|
if(menuItem.getItemId() == R.id.menuAbout) { |
|
menuMsg = "This application is an online shop for buying books."; |
|
} |
|
else if(menuItem.getItemId() == R.id.menuHelp) { |
|
menuMsg = "Click on each book title to see more details about that book."; |
|
} |
|
Toast toast = Toast.makeText(this, menuMsg, Toast.LENGTH_LONG); |
|
toast.show(); |
|
return true; |
|
} |
|
|
|
/* Create another Activity (or more) and connect them using Intent Filters. ( i.e. intents for sending a SMS, starting a voice call, open an URL, etc.) (2p) */ |
|
/* Created AddToCollection activity */ |
Create another Activity (or more) and connect them using Intent Filters. ( i.e. intents for sending a SMS, starting a voice call, open an URL, etc.) (2p)
|
/* LAB 4 */ |
|
/* Create another Activity (or more) and connect them using Intent Filters. ( i.e. intents for sending a SMS, starting a voice call, open an URL, etc.) (2p) */ |
|
Button btnAddToCollection = findViewById(R.id.btnAddToCollection); |
|
btnAddToCollection.setOnClickListener(new View.OnClickListener() { |
|
public void onClick(View view) { |
|
Intent intent = new Intent(); |
|
intent.setAction((Intent.ACTION_SEND)); |
|
intent.putExtra(Intent.EXTRA_TEXT, "Add a book to collection using..."); |
|
intent.setType("text/plain"); |
|
startActivity(Intent.createChooser(intent, "Add a book to collection using...")); |
|
} |
|
}); |
https://github.com/danapaduraru/AndroidLabs/blob/master/Lab2/app/src/main/java/com/example/lab2android/AddToCollection.java
Use dialog windows (AlertDialog) to interact with the user (username, password, search filter, etc.) (2p)
|
/* Use dialog windows (AlertDialog) to interact with the user (username, password, search filter, etc.) (2p) */ |
|
Button btnCreateCollection = findViewById(R.id.btnCreateCollection); |
|
btnCreateCollection.setOnClickListener(new View.OnClickListener() { |
|
public void onClick(View view) { |
|
AlertDialog builder = new AlertDialog.Builder(AddToCollection.this).create(); |
|
builder.setTitle("Create new Collection"); |
|
builder.setMessage("Your new collection has been created."); |
|
builder.setButton(AlertDialog.BUTTON_POSITIVE, "OK", |
|
new DialogInterface.OnClickListener() { |
|
public void onClick(DialogInterface dialog, int which) { |
|
dialog.dismiss(); |
|
} |
|
}); |
|
builder.show(); |