I have three buttons in my Activity with three separate onClickListeners set like I have done plenty times before. But one of the listeners does not react to a click event and I have no clue as to why. Here is the code segment:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_reminder_2);
//References to layout resources
edit2Back = (Button) findViewById(R.id.edit2Back);
edit2Next = (Button) findViewById(R.id.edit2Next);
edit2ChangeGPS = (Button) findViewById(R.id.edit2ChangeGPS);
//Assigning listeners to Buttons
edit2Back.setOnClickListener(listenerBack);
edit2Next.setOnClickListener(listenerNext);
edit2ChangeGPS.setOnClickListener(listenerChange);
}
final OnClickListener listenerNext = new OnClickListener() {
public void onClick(View v) {
Log.v("edit2Next","Click!");
db.open();
String sName = edit2ReminderName.getText().toString();
String sNote = edit2ReminderText.getText().toString();
int sRadius = Integer.parseInt(edit2Radius.getText().toString());
String sUnits = (String) edit2SpinnerUnits.getSelectedItem();
int sChecked = 0;
if (edit2Check.isChecked()) {
sChecked = 1;
}
db.insertReminder(sName, sNote, lat, lon, sRadius, sUnits, sChecked);
db.close();
Intent intent = new Intent(context, Reminders.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
};
All my other listener I wrote in the same fashion and they work perfectly fine, but this one does not. I looked all over the code but could not find the reason. The listener does not start at all, not even the Log.v instruction runs. Thanks for your advice!
EDIT:
This is part of the XML code where i define my Buttons:
<LinearLayout
android:id="@+id/edit2ControlLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/azure"
android:padding="15dp"
android:orientation="horizontal" >
<Button
android:id="@+id/edit2Back"
android:layout_height="wrap_content"
android:layout_width="0.0dip"
android:text="Back"
android:background="@drawable/round_button_violet"
android:textColor="@color/azure"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_weight="1.0"
android:layout_marginRight="5dp" />
<Button
android:id="@+id/edit2Next"
android:layout_height="wrap_content"
android:layout_width="0.0dip"
android:text="Next"
android:background="@drawable/round_button_violet"
android:textColor="@color/azure"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_weight="1.0"
android:enabled="false" />
</LinearLayout>
Please remove android:enabled=”false” in your next button code in-order to work next button.