Dynamic contentDescription attribute on the action button.

This commit is contained in:
Igor B. Poretsky 2016-05-13 23:23:41 +03:00
parent 1f14512ea0
commit 1a560aa700
2 changed files with 6 additions and 3 deletions

View file

@ -50,7 +50,6 @@
<ImageButton
android:id="@+id/stop"
android:contentDescription="@string/animate_route_off"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_gravity="center_vertical"

View file

@ -39,9 +39,11 @@ public class DashSimulateFragment extends DashBaseFragment {
boolean routeAnimating = loc.getLocationSimulation().isRouteAnimating();
((TextView) getView().findViewById(R.id.name)).setText(routeAnimating ? R.string.animate_route_off
: R.string.animate_route);
((ImageButton) getView().findViewById(R.id.stop)).setImageDrawable(
ImageButton actionButton = (ImageButton) getView().findViewById(R.id.stop);
actionButton.setImageDrawable(
!routeAnimating ? getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_play_dark)
: getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_rec_stop));
actionButton.setContentDescription(getString(routeAnimating ? R.string.animate_route_off : R.string.animate_route));
}
@ -64,7 +66,9 @@ public class DashSimulateFragment extends DashBaseFragment {
}
};
item.setOnClickListener(listener);
((ImageButton) item.findViewById(R.id.stop)).setOnClickListener(listener);
ImageButton actionButton = (ImageButton) item.findViewById(R.id.stop);
actionButton.setOnClickListener(listener);
actionButton.setContentDescription(getString(R.string.animate_route));
((TextView) item.findViewById(R.id.name)).setText(R.string.animate_route);
item.findViewById(R.id.divider).setVisibility(View.VISIBLE);