There is a button in the layout of the rows of my list.I need to change the action based on the text in the button.These text can be "Revert" or "Directions". I have created my own adapter class which make changes if the button text is "Revert".The onclick function mentioned in the layout will be working for the button text "Directions".
//This is my Onclick() function mentioned in the layout
public void changecolour(View v) {
LinearLayout vwParentRow = (LinearLayout) v.getParent();
final Button btnChild = (Button) vwParentRow.getChildAt(2);
if (btnChild.getText().toString().equals("Directions")) {
Intent directiosin = new Intent(getApplicationContext(),
Directions.class);
startActivity(directiosin);
}
The portion in the adapter class for the text "Revert" shown below.
if (btnChild.getText().toString().equals("Revert")) {
btnChild.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
btnChild.setText("Directions");
checkbox.setChecked(false);
getItem(position).setCompleted(false);
if (0 <= list.get(position).getStatus()
&& list.get(position).getStatus() < 5) {
text.setTextColor(Color.BLUE);
} else if (5 <= list.get(position).getStatus()
&& list.get(position).getStatus() < 10) {
text.setTextColor(Color.parseColor("#DD7500"));
} else {
text.setTextColor(Color.RED);
}
}
});
}
When I click on the "Directions" button The intent is successfully called .When I click on "Revert" button,button text is changed to "Directions" .But when this button is clicked the "directionsIn" intent is not called.