mardi 28 avril 2020

I am stuck in "If" & "Else" function one of my android app

I my app I am fetch some text data from the server and showing this text data in the TextView. Here is something works fine. I am add an little arrow ImageView right to the TextView and this TextView is expandable so when TextView is more then 2 lines and if anyone click this TextView it expand and again click to shrink and I am also add an little arrow image right to the TextView (so user understant that it is an expandable text), here is everything is fine all code are works perfectly but now I want to remove this litter arrow image when the TextView is under 2 lines and when TextView is more then 2 lines it show. I want to tell you one more thing that I am also add a rotation in the arrow image so when the user click the text the little arrow image rotate the 180 degree and also text is expand and when user click the text second time arrow image again rotate to his previous position and text is shrink in 2 lines.

I want to remove this little arrow when the text is under 2 lies I do not want to remove the arrow image when text line more then 2, I'm guessing you understand.

I am new to the Java Code and I am learning is language so now I want to learn how to do this implementation in my app, I have add my code below so that you can understand batter.

textViewMyVideoTitle.setText(videoLists.get(0).getVideo_title());
my_title_layout_expand.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View view) {
    if (isTextViewClicked) {
      //This will shrink textview to 2 lines if it is expanded.
      textViewMyVideoTitle.setText(videoLists.get(0).getVideo_title());
      myTitleImageView.setRotation(imageView.getRotation() + 0);
      myTitleImageView.setVisibility(View.VISIBLE);
      textViewMyVideoTitle.setMaxLines(2);
      isTextViewClicked = false;
    } else {
      //This will expand the textview if it is of 2 lines
      textViewMyVideoTitle.setText(videoLists.get(0).getVideo_title());
      myTitleImageView.setRotation(imageView.getRotation() - 180);
      myTitleImageView.setVisibility(View.VISIBLE);
      textViewMyVideoTitle.setMaxLines(Integer.MAX_VALUE);
      isTextViewClicked = true;
    }
  }
});

So anybody can help me to achieve this code

enter image description here enter image description here

Aucun commentaire:

Enregistrer un commentaire