You should get the index of position of the item and then pass it to
arrayList to remove the item use position as index to ArrayList to remove
the item from arrayList.

On Thu, Mar 24, 2016 at 10:47 PM, Mike <mikesno...@gmail.com> wrote:

>
>
> public class Notes extends AppCompatActivity {
>
>     Button save;
>     ArrayList<String> addArray = new ArrayList<String>();
>     EditText txt;
>     ListView show;
>
>
>     @Override
>     protected void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.activity_notes);
>
>         txt = (EditText) findViewById(R.id.textInput);
>         show = (ListView) findViewById(R.id.listView);
>         save = (Button) findViewById(R.id.saveButton);
>
>         final ArrayAdapter<String> adapter = new 
> ArrayAdapter<String>(Notes.this, android.R.layout.simple_list_item_1, 
> addArray);
>
>         save.setOnClickListener(new View.OnClickListener() {
>             @Override
>             public void onClick(View v) {
>
>                 String getInput = txt.getText().toString();
>
>                 if (addArray.contains(getInput)) {
>                     Toast.makeText(getBaseContext(), "Note already added!", 
> Toast.LENGTH_LONG).show();
>                 } else if (getInput == null || getInput.trim().equals("")) {
>                     Toast.makeText(getBaseContext(), "Input required!", 
> Toast.LENGTH_LONG).show();
>                 } else {
>                     addArray.add(getInput);
>
>                     show.setAdapter(adapter);
>                     ((EditText) findViewById(R.id.textInput)).setText(" ");
>                 }
>             }
>         });
>
>
>         show.setOnItemLongClickListener(new 
> AdapterView.OnItemLongClickListener() {
>             @Override
>             public boolean onItemLongClick(AdapterView<?> av, View v, int 
> pos, long id) {
>
>
>
>
>
>
>                 return true;
>             }
>         });
>
>     }
>
>
> }
>
>
>
>
> What would  I need to add to get the OnItemLongClickListener to delete
> specific items on the list view?
> Thanks
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to android-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/android-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/android-developers/838730d0-9d4f-4e80-a5a8-e7bbf729aeb3%40googlegroups.com
> <https://groups.google.com/d/msgid/android-developers/838730d0-9d4f-4e80-a5a8-e7bbf729aeb3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CABHzXATe34F_NrC2Z7tfFQYG%2B%3DCwEbBVqNhuSucHg2SYqLVzAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to