-1

i have one button Create in programmatically i need to implement Both onClick and OnTouch to That Button in same time i want implement button focus_change.

Am implemented like this

ImageView Settings_Button = new ImageView(this);       
        Settings_Button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {    
                //UtilityClass.focusOnallviews(view);
                Intent newIntent = new Intent(activity.getBaseContext(), ProfileSettingActivity.class);
                activity.startActivity(newIntent);           
            }
        });

Note: i want implement state_focused and state_pressed when i interact with button how can solve this issue.

Charles
  • 50,943
  • 13
  • 104
  • 142
NagarjunaReddy
  • 8,621
  • 10
  • 63
  • 98

1 Answers1

1

You can use OnTouch event

ImageView Settings_Button = new ImageView(this);       
Settings_Button.setOnTouchListener(new OnTouchListener(){
    @Override
    public boolean onTouch(View arg0, MotionEvent arg1) {
        switch(arg1.getAction()){
           case MotionEvent.ACTION_DOWN:
                     // Button is pressed. Change the button to pressed state here
                break;

          case MotionEvent.ACTION_MOVE:
                     // Button is being touched and swiped
                break;

          case MotionEvent.ACTION_UP:
                     // Button is released. Change the button to unpressed state here.
                    Intent newIntent = new Intent(activity.getBaseContext(),ProfileSettingActivity.class);
                    activity.startActivity(newIntent);     
                break;

        }
       });
John
  • 8,846
  • 8
  • 50
  • 85