0
votes

Idk what to do so basically i was creating a button which opens new activity on long press could u fix this?

  @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    button = (Button) findViewById(R.id.button);

    defineView();
    handleIntent();
    defineActionBar();
    checkPermission();

    button.setOnLongClickListener(new View.OnCLongClickListener() {
        @Override
        public void onLongClick(View v) {
            openWebsite();
        }
    });
}



public void openWebsite() {
    Intent intent = new Intent(this, Website.class);
    startActivity(intent);
}
1

1 Answers

0
votes

onLongClick returns a boolean, not a void. Change that and make it return true (assuming you want to consume the touch).