Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Java
@Override 
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
        super.onCreateContextMenu(menu, v, menuInfo);
        menu.setHeaderTitle("Select The Action");  
        menu.add(0, v.getId(), 0, "remove");//groupId, itemId, order, title 
        menu.add(0, v.getId(), 0, "SMS"); 

} 

@Override  
public boolean onContextItemSelected(MenuItem item){ 
	AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
	
	 bcc=Double.parseDouble(tv1.getText().toString());
	  int itemCount = l1.getCount();
	  int i=0;
	 
 	
        if(item.getTitle()=="remove"){
        	if (c1=="mosab"){
             
                  	adapter.remove(strAA.get(i));
                  	bcc=bcc-20;
                      	
                  	tv1.setText(Double.toString(bcc));
        	}
        	else if (c2 == "ahmad"){
        		adapter.remove(strAA.get(i));
              	bcc=bcc-30;
                  	
              	tv1.setText(Double.toString(bcc));
        	}
        
        	 
        }
        else if(item.getTitle()=="SMS"){
        	Toast.makeText(getApplicationContext(),"sending sms code",Toast.LENGTH_LONG).show();
        }else{
           return false;
        }  
        
       return true;
  }
Posted
Updated 17-Aug-14 21:19pm
v2
Comments
Richard MacCutchan 18-Aug-14 3:20am    
Where are you trying to remove items? Please give some proper detail of your problem, we cannot guess what you want.
Mosab AH Ah 18-Aug-14 10:18am    
I do not know the English language .. I'll try that brought the information which I want When you delete an item from the list view that is certain to lose the value of the text view at the same time that the omitted element ..
I hope to be reached idea
Can I send you the full code .. I Beginner
Thank you
Mosab AH Ah 18-Aug-14 10:36am    
I am the problem when pressing the remove in the context menu does not delete the same value set by, delete the value of the other
Richard MacCutchan 18-Aug-14 11:01am    
There are a number of variables that you are comparing or using, that are set in some other place. Also, in onContextItemSelected you set i to zero and then use it as an index into strAA; what is that supposed to do?

So it looks like you remove the first item from strAA and then set tv1 to some value, but none of it is very clear.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900