Android Studio: Expandable TextView

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 ต.ค. 2024

ความคิดเห็น • 12

  • @davidmatano390
    @davidmatano390 9 หลายเดือนก่อน

    Precise and to the point. We need more guys like you, I'm subscribing right now!

    • @emarancoding
      @emarancoding  8 หลายเดือนก่อน

      Thanks! Really happy to get feedback like that!

  • @henrygnoobgamer6610
    @henrygnoobgamer6610 7 วันที่ผ่านมา

    Thank you very much

  • @isratjahanpayel9057
    @isratjahanpayel9057 9 หลายเดือนก่อน

    very helpfull video love from bangladesh

  • @dedanr
    @dedanr ปีที่แล้ว +1

    Precise and to the point. Thank you
    Would it be possible to automatically collapse one heading if another is clicked to avoid long scrolls?

    • @emarancoding
      @emarancoding  ปีที่แล้ว +1

      Thanks!
      Yeah, sure, that's acutally quite easy! You could just add
      text2.setVisibility(View.GONE);
      button2.setImageResource(R.drawable.ic_arrow_down);
      to the if statement of button1.setOnClickListener and
      text1.setVisibility(View.GONE);
      button1.setImageResource(R.drawable.ic_arrow_down);
      to the if statement of button1.setOnClickListener, respectively.
      So the whole part would be:
      button1.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      if (text1.getVisibility() == View.GONE) {
      text1.setVisibility(View.VISIBLE);
      button1.setImageResource(R.drawable.ic_arrow_up);
      text2.setVisibility(View.GONE);
      button2.setImageResource(R.drawable.ic_arrow_down);
      } else {
      text1.setVisibility(View.GONE);
      button1.setImageResource(R.drawable.ic_arrow_down);
      }
      }
      });
      button2.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      if (text2.getVisibility() == View.GONE) {
      text2.setVisibility(View.VISIBLE);
      button2.setImageResource(R.drawable.ic_arrow_up);
      text1.setVisibility(View.GONE);
      button1.setImageResource(R.drawable.ic_arrow_down);
      } else {
      text2.setVisibility(View.GONE);
      button2.setImageResource(R.drawable.ic_arrow_down);
      }
      }
      });
      Hope that helps!

  • @sakibhossin2992
    @sakibhossin2992 ปีที่แล้ว

    Very helpful. Thanks a lot.

  • @santos7102
    @santos7102 2 หลายเดือนก่อน

    Hello, not working in Koala versión. I copy your code exactly, app run but no show any error.

  • @dustbin-l6f
    @dustbin-l6f 10 หลายเดือนก่อน

    Very nice 👍🏻👍🏻🙂

  • @ivanadrianmunoz2367
    @ivanadrianmunoz2367 ปีที่แล้ว

    helpful, thanks

  • @ROGELDominicM
    @ROGELDominicM ปีที่แล้ว

    where i can email you ? i have some question