Skip to content

Commit

Permalink
Created logic to change icon when click (Escola-em-Casa#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
omateusp committed Oct 8, 2020
1 parent 00ebaa6 commit b8c4fce
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
Expand All @@ -19,6 +20,7 @@
public class QuestionsActivity extends AppCompatActivity {

List<TextView> textViews = new ArrayList<>();
List<ImageView> imageViews = new ArrayList<>();


@Override
Expand Down Expand Up @@ -68,6 +70,10 @@ protected void onCreate(Bundle savedInstanceState) {
textViews.get(1).setVisibility(View.GONE);
textViews.add(2,(TextView) findViewById(R.id.route_answer));
textViews.get(2).setVisibility(View.GONE);

imageViews.add(0, (ImageView) findViewById(R.id.sponsored_data_icon));
imageViews.add(1, (ImageView) findViewById(R.id.meet_icon));
imageViews.add(2, (ImageView) findViewById(R.id.route_icon));
}

@Override
Expand All @@ -92,15 +98,18 @@ void slide(Context ctx, View v, Boolean down) {
}

public void toggle_contents(View v) {
TextView answerView = textViews.get(Integer.parseInt((String) v.getTag()));
int id = Integer.parseInt((String) v.getTag());
TextView answerView = textViews.get(id);


if (answerView.isShown()) {
slide(this, answerView, false);
answerView.setVisibility(View.GONE);
imageViews.get(id).setImageResource(R.drawable.baseline_expand_more_24);
} else {
answerView.setVisibility(View.VISIBLE);
slide(this, answerView, true);
imageViews.get(id).setImageResource(R.drawable.baseline_expand_less_24);
}
}
}

0 comments on commit b8c4fce

Please sign in to comment.