如何以从字符到字符串的反向显示文本

How to Display the text in Reverse from char to String


我试图显示文本,但它显示在错误的视图中。我想反向显示 Textview 。我试过这段代码

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);
}

尝试以下方法

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

只需反转你的循环

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

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

希望对您有所帮助

当您从 0n 迭代时,第一个字符首先被引用并将被添加到顶部。因为你想反过来,迭代 n0