1

enter image description here
I tried to display the text but it is displaying in wrong view. I want to display the Textview in reverse. I tried this code

String subMenuId = (String) key[position];
String subMenuName = subMenuTable.get(subMenuId);
for (int x = 0; x < subMenuName.length(); x++) {
    int splitword = subMenuName.charAt(x);
    char c = (char) splitword;
    TextView product = new TextView(con);
    product.setText(String.valueOf(c));
    product.setRotation(-90);
    holder.tv.setGravity(Gravity.CENTER_VERTICAL);
    product.setTextSize(12);
    holder.tv.setPadding(5,0,5,0);
    product.setTextColor(Color.BLACK);
    product.setTypeface(null, Typeface.BOLD);
    holder.tv.addView(product);
}
Let'sRefactor
  • 3,303
  • 4
  • 27
  • 43
Dev Tamil
  • 629
  • 1
  • 9
  • 25

2 Answers2

2

Try the following

String reversedString = new StringBuilder("LIKE").reverse().toString()

Atif Farrukh
  • 2,219
  • 2
  • 25
  • 47
1

Just reverse your loop

i.e.

for (int x = 0; x < subMenuName.length(); x++)

to

for (int x = subMenuName.length() -1; x >=0 ; x--)

Hope it helps

When you iterate from 0n first char get referred first and will be added to top. since you want it in reverse, iterate n0

Let'sRefactor
  • 3,303
  • 4
  • 27
  • 43