• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Method falls due to other method

AlexeyS

Newbie
Mar 16, 2017
20
2
I have two different methods that do different things. When the is open and second close, All work wonderful, when the second method open and first close, all work wonderful. the problem happened when they both open.In this case the first method falls(i click on item and for a second see alert dialog with two options : yes/no). Can you please tell me where is error?
Thank you


/*first method*/
Code:
 public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

        AlertDialog dialog = new AlertDialog.Builder(this)
                 .setMessage("Choose one of the options!")
                .setPositiveButton("Yes", new HandleAlertDialog())
                .setNeutralButton("No",new HandleAlertDialog())
                .setCancelable(false)
                .create();
                dialog.show();
  }

   public  class  HandleAlertDialog implements DialogInterface.OnClickListener
   {
       [USER=1021285]@override[/USER]
       public void onClick(DialogInterface dialog, int which) {

           if (which==-1){
               moh.deleteNameByNumber(id);
           }

       }
   }


  /*second option*/
   public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Name n = (Name) nameAdapter.getItem(position);
    Intent i= new Intent(MainActivity.this, Information.class);
     startActivityForResult(i,0);

   }
 
Last edited by a moderator:

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones