Question

6. What is lint ? Give two examples where lint will give erros 7. (A) Explain the differences between Option menu and Context menu. (B) Create an App with a single activity. The activity houses a list view. The list view should show names of any five diseases. On long clicking on any list iten(disease name) should show a menu, Delete On clicking delete should delete the particular disease from the list view ning tasks.

7)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Option menu:The options menu is the primary collection of menu items for an activity. It's where you should place actions that have a global impact on the app, such as "Search," "Compose email," and "Settings."​

A context menu: is a floating menu that appears when the user performs a long-click on an element. It provides actions that affect the selected content or context frame​.
for the given question we need to use a context menu to perform delete on long press of item

Activity main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ListView
        android:id="@+id/list_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</android.support.constraint.ConstraintLayout>

MainActivity.java

package com.example.android.listexample;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
   ListView list_view;
   List<String> list = new ArrayList<String>();
   ArrayAdapter<String> adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        list_view= (ListView) findViewById(R.id.list_view);
        list.add("cold");
        list.add("fever");
        list.add("cough");
        list.add("cancer");
        list.add("headache");
        adapter = new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_1,list);
        list_view.setAdapter(adapter);
        registerForContextMenu(list_view);


    }@Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo){
        super.onCreateContextMenu(menu,v,menuInfo);

        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.main_context_menu,menu);

    }
    public boolean onContextItemSelected(MenuItem item){
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
        switch (item.getItemId()) {
            case R.id.delete_id:
                adapter.remove(adapter.getItem(info.position));
            default:
                return super.onContextItemSelected(item);

        }
    }
}
min_context_menu.xml

menu xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <item android:id="@+id/delete_id"
        android:title="Delete Item"

    />


</menu>
Add a comment
Know the answer?
Add Answer to:
7) 6. What is lint ? Give two examples where lint will give erros 7. (A)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 7. Give two examples where an acetylide anion is used as a nucleophile in a substitution reaction with an alkylating...

    7. Give two examples where an acetylide anion is used as a nucleophile in a substitution reaction with an alkylating agent. (4 pts) 8. Show how you would convert 1,1-dichlorohexane into 1-hexyne. All the appropriate chemical equations must be shown. (4 pts) 9. Give examples which show the effect of double dehydrohalogenation of both geminal and vicinal dihalides. The reagents must be included. (4 pts)

  • Assignment #2: List - Array Implementation Review pages 6-7 in "From Java to C++" notes. Due...

    Assignment #2: List - Array Implementation Review pages 6-7 in "From Java to C++" notes. Due Friday, February 9th, 2017 @ 11:59PM EST Directions Create a List object. Using the following definition (List.h file is also in the repository for your convenience) for a list, implement the member functions (methods) for the List class and store the implementation in a file called List.cpp. Use an array to implement the list. Write the client code (the main method and other non-class...

  • 6. Give 3 examples of nursing questions that can be asked to assess for malnourishment? Identify...

    6. Give 3 examples of nursing questions that can be asked to assess for malnourishment? Identify 5 physical signs of malnourishment? 8pts 7. In the acute care setting nurses are essential for nutritional support. Identify three things nurses can do to promote intake of nutrition.3 pts 8. Compare and Contrast enteral feedings with parenteral feedings. Why would one be chosen over the other? List 5 similarities/differences or indications for treatment. 10 pts 9. In order of progression list the therapeutic...

  • C++ : Please include complete source code in answer This program will have names and addresses...

    C++ : Please include complete source code in answer This program will have names and addresses saved in a linked list. In addition, a birthday and anniversary date will be saved with each record. When the program is run, it will search for a birthday or an anniversary using the current date to compare with the saved date. It will then generate the appropriate card message. Because this will be an interactive system, your program should begin by displaying a...

  • Microsoft Project Assignment Description A system development project has been defined to contain the following list of...

    Microsoft Project Assignment Description A system development project has been defined to contain the following list of activities along with their estimated times for completion. The project will start on 5/1/2019. Project Data Provided: Activity ID Activity Name Days Predecessors Optimistic(O) Realistic(R) Pessimistic(P) 1 Gather Requirement 1 2 3 2 Analyze processes 1 2 6 1 3 Define DFDs 0.5 1 1.5 2 4 Design Processes 2 7 12 2 5 Design database 4 7 22 3 6 Design UI...

  • Part IV- Sustainability and job costing 39. Give two examples of environmental and/or social information that...

    Part IV- Sustainability and job costing 39. Give two examples of environmental and/or social information that could be included on the job cost record to give management a more encompassing view of the resources used in making the product. Oro 40. List four possible uses of job-related sustainability information 41. What is the goal of EPR laws? How do they work? 42. Why is e-waste an issue? Part V- How do managers deal with underallocated or overallocated manufacturing overhead? (LO...

  • Objectives This is one of three major programming projects this semester. You should NOT collaborate on...

    Objectives This is one of three major programming projects this semester. You should NOT collaborate on this project. While you may ask for assistance in debugging, this project should be ENTIRELY your own work. Objectives include: . Use local variables. • Use arithmetic expressions. • Use Scanner to input values. • Use a class constant. • Use of nested branches. • Use for loxops. • Use of methods. • Use of arrays. Hand-in Requirements All projects and laboratories will be...

  • do numbers 4-8 4. Given any directory, use the Is command to display: • all files...

    do numbers 4-8 4. Given any directory, use the Is command to display: • all files and sub-directories starting with the letter "D" (note do not list anything in any sub-directory) • its immediate sub-directories (sub-directories only, and no other ordinary files) its immediate hidden sub-directories only - take a screenshot (#3-3) that clearly shows the command and the result. 5. Assume that the following files are in the working directory: $ ls intro notesb ref2 section 1 section3 section4b...

  • You will be developing an Advising Scheduling Management System (ASMS) that can be used managing the advising appointments for Salisbury University professors and their advisees (students). ASMS shoul...

    You will be developing an Advising Scheduling Management System (ASMS) that can be used managing the advising appointments for Salisbury University professors and their advisees (students). ASMS should have the following functionalities: - There are three kinds of users: professor, student and admin. When ASMS starts, a login screen asks user which kinds of users and then asks user id and password. If id or password are incorrect, issue a warning and redisplay the login screen. - When an admin...

  • HELLO, PLEASE TAKE TIME TO ANSWER THIS QUESTION. PLESE ENSURE ITS CORRECT AND SHOW THAT THE...

    HELLO, PLEASE TAKE TIME TO ANSWER THIS QUESTION. PLESE ENSURE ITS CORRECT AND SHOW THAT THE PROGRAM RUNS. Task 1: Enforcing const-ness throughout Your first job will be to go through all of the code and decide which functions should be declared const. You should find several places throughout the program where this makes sense. We will also make the id data member in the Customer class const , as once a customer has been created their ID will never...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT