I have an activity which get a reference to a specific ImageView inside a layout. I want that whenever this button is clicked, it will bring up a chooser which will give the user the ability to choose which app he would like to use to share this data.
The problem is that I want also the image to change on touch event. For instance, if the motion event is Action_Down, the image will be A and if the motion event is Action_Up the image will be B. It seems that this on touch code disturb the onclicklistener and therefore causing it not to work. Because of that, the on touch listener performs well but the onclicklisener does nothing, especially not bringing up a chooser.
Here is my On Touch code:
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
ImageView share = (ImageView) v;
switch(event.getAction()) {
case MotionEvent.ACTION_DOWN:
share.setImageResource(R.drawable.rsz_share_1);
break;
case MotionEvent.ACTION_UP:
share.setImageResource(R.drawable.rsz_share_alt_1);
break;
}
return true;
}
Here is my On Click Listener:
share.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT,"I'm at stage ");
Statistics.this.startActivity(Intent.createChooser(shareIntent, String.valueOf(R.string.chooseTitle)));
}
});
What could be the problem?