How to handle long click in multi image viewHow to align views at the bottom of the screen?How to prevent a dialog from closing when a button is clickedHow to start new activity on button clickAllow multi-line in EditText view in Android?Android: Why does long click also trigger a normal click?How to handle button clicks using the XML onClick within Fragmentshow to implement a long click listener on a listviewHow to create RecyclerView with multiple view type?Handle on item long click on recycler viewAndroid custom image view shape

How to make all magic-casting innate, but still rare?

I have found ports on my Samsung smart tv running a display service. What can I do with it?

Is swap gate equivalent to just exchanging the wire of the two qubits?

How to use random to choose colors

Digital signature that is only verifiable by one specific person

Co-worker is now managing my team. Does this mean that I'm being demoted?

How to write a nice frame challenge?

How would Japanese people react to someone refusing to say “itadakimasu” for religious reasons?

Why swap space doesn't get filesystem check at boot time?

Print the new site header

1960s sci-fi anthology with a Viking fighting a U.S. army MP on the cover

Showing that a language is NP Complete (advice)

How can the US president give an order to a civilian?

In a Fish that is not a Fish

What is the precise meaning of "подсел на мак"?

Should I email my professor to clear up a (possibly very irrelevant) awkward misunderstanding?

Expand command in an argument before the main command

How to make a villain when your PCs are villains?

Leaving job close to major deadlines

Is a sequel allowed to start before the end of the first book?

Why do you need to heat the pan before heating the olive oil?

Justifying Affordable Bespoke Spaceships

What is "dot" sign in •NO?

How to avoid offending original culture when making conculture inspired from original



How to handle long click in multi image view


How to align views at the bottom of the screen?How to prevent a dialog from closing when a button is clickedHow to start new activity on button clickAllow multi-line in EditText view in Android?Android: Why does long click also trigger a normal click?How to handle button clicks using the XML onClick within Fragmentshow to implement a long click listener on a listviewHow to create RecyclerView with multiple view type?Handle on item long click on recycler viewAndroid custom image view shape






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I have 8-numbers of ImageView in my layout and I had set the LongClickListner to all of the ImageView. If the user long click on the image (any image), the image will be saved in the gallery. But my problem here is when the user long click on 8th Image, the 1st or others (1 of them) will saved in the gallery. What I want is when the user long click on 8th image, the 8th image will saved not the others.



 @Override
public boolean onContextItemSelected(MenuItem item)
switch (item.getItemId())
case R.id.saveImage:
if(img1.isLongClickable() )
BitmapDrawable bitmapDrawable = (BitmapDrawable)img1.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img2.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img2.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img3.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img3.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img4.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img4.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img5.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img5.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img6.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img6.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img7.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img7.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img8.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img8.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;



return super.onContextItemSelected(item);










share|improve this question

















  • 1





    Show full code snippet. Can't understand the existing one.

    – bhagyawant biradar
    Mar 25 at 4:58

















-1















I have 8-numbers of ImageView in my layout and I had set the LongClickListner to all of the ImageView. If the user long click on the image (any image), the image will be saved in the gallery. But my problem here is when the user long click on 8th Image, the 1st or others (1 of them) will saved in the gallery. What I want is when the user long click on 8th image, the 8th image will saved not the others.



 @Override
public boolean onContextItemSelected(MenuItem item)
switch (item.getItemId())
case R.id.saveImage:
if(img1.isLongClickable() )
BitmapDrawable bitmapDrawable = (BitmapDrawable)img1.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img2.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img2.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img3.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img3.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img4.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img4.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img5.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img5.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img6.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img6.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img7.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img7.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img8.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img8.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;



return super.onContextItemSelected(item);










share|improve this question

















  • 1





    Show full code snippet. Can't understand the existing one.

    – bhagyawant biradar
    Mar 25 at 4:58













-1












-1








-1








I have 8-numbers of ImageView in my layout and I had set the LongClickListner to all of the ImageView. If the user long click on the image (any image), the image will be saved in the gallery. But my problem here is when the user long click on 8th Image, the 1st or others (1 of them) will saved in the gallery. What I want is when the user long click on 8th image, the 8th image will saved not the others.



 @Override
public boolean onContextItemSelected(MenuItem item)
switch (item.getItemId())
case R.id.saveImage:
if(img1.isLongClickable() )
BitmapDrawable bitmapDrawable = (BitmapDrawable)img1.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img2.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img2.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img3.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img3.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img4.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img4.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img5.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img5.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img6.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img6.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img7.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img7.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img8.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img8.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;



return super.onContextItemSelected(item);










share|improve this question














I have 8-numbers of ImageView in my layout and I had set the LongClickListner to all of the ImageView. If the user long click on the image (any image), the image will be saved in the gallery. But my problem here is when the user long click on 8th Image, the 1st or others (1 of them) will saved in the gallery. What I want is when the user long click on 8th image, the 8th image will saved not the others.



 @Override
public boolean onContextItemSelected(MenuItem item)
switch (item.getItemId())
case R.id.saveImage:
if(img1.isLongClickable() )
BitmapDrawable bitmapDrawable = (BitmapDrawable)img1.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img2.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img2.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img3.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img3.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img4.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img4.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img5.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img5.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img6.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img6.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img7.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img7.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;
else if(img8.isLongClickable())
BitmapDrawable bitmapDrawable = (BitmapDrawable)img8.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
Random random = new Random();
int x = random.nextInt(1000000);
saveImageUtils.insertImage(getActivity().getContentResolver(),bitmap,String.valueOf(x));
//SaveImage(bitmap);
Toast.makeText(getContext(), "Image Saved to Device", Toast.LENGTH_SHORT).show();
break;



return super.onContextItemSelected(item);







android onlongclicklistener






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 25 at 4:49









David AdamDavid Adam

6211




6211







  • 1





    Show full code snippet. Can't understand the existing one.

    – bhagyawant biradar
    Mar 25 at 4:58












  • 1





    Show full code snippet. Can't understand the existing one.

    – bhagyawant biradar
    Mar 25 at 4:58







1




1





Show full code snippet. Can't understand the existing one.

– bhagyawant biradar
Mar 25 at 4:58





Show full code snippet. Can't understand the existing one.

– bhagyawant biradar
Mar 25 at 4:58












1 Answer
1






active

oldest

votes


















1














What you presented above is like this:



  1. Apparently your ImageView's have OnLongClickListeners assigned

  2. User is clicking toolbar's menu item R.id.saveImage and you're trying to save image based on isLongClickable indication

If true, the above is wrong because isLongClickable is basically just indication that given control has OnLongClickListener assigned.



What you should be doing: either do your saving inside every respective OnLongClickListener(and its onLongClick will give you the view, that is, ImageView) OR if you need to do the saving only upon R.id.saveImage click, then in OnLongClickListener you should somehow tell your app that given ImageView was long clicked, and then upon R.id.saveImage click, iterate through recorded list of ImageView long clicks and perform the saving.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331417%2fhow-to-handle-long-click-in-multi-image-view%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    What you presented above is like this:



    1. Apparently your ImageView's have OnLongClickListeners assigned

    2. User is clicking toolbar's menu item R.id.saveImage and you're trying to save image based on isLongClickable indication

    If true, the above is wrong because isLongClickable is basically just indication that given control has OnLongClickListener assigned.



    What you should be doing: either do your saving inside every respective OnLongClickListener(and its onLongClick will give you the view, that is, ImageView) OR if you need to do the saving only upon R.id.saveImage click, then in OnLongClickListener you should somehow tell your app that given ImageView was long clicked, and then upon R.id.saveImage click, iterate through recorded list of ImageView long clicks and perform the saving.






    share|improve this answer



























      1














      What you presented above is like this:



      1. Apparently your ImageView's have OnLongClickListeners assigned

      2. User is clicking toolbar's menu item R.id.saveImage and you're trying to save image based on isLongClickable indication

      If true, the above is wrong because isLongClickable is basically just indication that given control has OnLongClickListener assigned.



      What you should be doing: either do your saving inside every respective OnLongClickListener(and its onLongClick will give you the view, that is, ImageView) OR if you need to do the saving only upon R.id.saveImage click, then in OnLongClickListener you should somehow tell your app that given ImageView was long clicked, and then upon R.id.saveImage click, iterate through recorded list of ImageView long clicks and perform the saving.






      share|improve this answer

























        1












        1








        1







        What you presented above is like this:



        1. Apparently your ImageView's have OnLongClickListeners assigned

        2. User is clicking toolbar's menu item R.id.saveImage and you're trying to save image based on isLongClickable indication

        If true, the above is wrong because isLongClickable is basically just indication that given control has OnLongClickListener assigned.



        What you should be doing: either do your saving inside every respective OnLongClickListener(and its onLongClick will give you the view, that is, ImageView) OR if you need to do the saving only upon R.id.saveImage click, then in OnLongClickListener you should somehow tell your app that given ImageView was long clicked, and then upon R.id.saveImage click, iterate through recorded list of ImageView long clicks and perform the saving.






        share|improve this answer













        What you presented above is like this:



        1. Apparently your ImageView's have OnLongClickListeners assigned

        2. User is clicking toolbar's menu item R.id.saveImage and you're trying to save image based on isLongClickable indication

        If true, the above is wrong because isLongClickable is basically just indication that given control has OnLongClickListener assigned.



        What you should be doing: either do your saving inside every respective OnLongClickListener(and its onLongClick will give you the view, that is, ImageView) OR if you need to do the saving only upon R.id.saveImage click, then in OnLongClickListener you should somehow tell your app that given ImageView was long clicked, and then upon R.id.saveImage click, iterate through recorded list of ImageView long clicks and perform the saving.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 5:05









        rorror

        601611




        601611





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55331417%2fhow-to-handle-long-click-in-multi-image-view%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해