Only on 2nd click the button loads the new activity.
Usually this problem happens often when I define an onCLick() method in the .xml and also have it in the activity. This is here not the case.
<Button
android:id="@+id/settingsBtn"
android:layout_width="192dp"
android:layout_height="60dp"
android:layout_above="@+id/exitBtn"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_gravity="end|bottom"
android:layout_marginStart="-2dp"
android:layout_marginEnd="2dp"
android:layout_marginBottom="24dp"
android:background="@android:color/black"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="@string/settings"
android:textColor="@android:color/white"
android:textSize="24sp" />
private Button mSettingsButton;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
.
.
.
connectUiElements();
setUpUiListeners();
}
.
.
.
private void connectUiElements() {
mSettingsButton = (Button) findViewById(R.id.settingsBtn);
}
private void setUpUiListeners() {
mSettingsButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),
SettingsActivity.class);
startActivity(intent);
}
}
);
}
Usually I would expect, that the buttons works when I click once.