首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >SetText逐行

SetText逐行
EN

Stack Overflow用户
提问于 2016-01-12 14:27:28
回答 1查看 50关注 0票数 0

我试图将TextView设置为读取来自算法的数字结果。我想把它们一排排地分类。这些数字现在显示在彼此的旁边。我怎样才能让他们一排排?

我创建了一个新的自定义对话框,其中包含了这个名为TextView的Peak_num,但是我不能更进一步地对它们进行排序。我希望有人能帮我。

代码语言:javascript
运行
复制
 List<Integer> List_Of_Peaks = findPeaks(String_TO_List);
 dialog.setTitle("my Dialog");
 dialog.setContentView(R.layout.customdialog);
 dialog.show();
 Log.i(TAG, "Peaks" + List_Of_Peaks);   
 Peaks_num = (TextView) dialog.findViewById(R.id.Peak_Num);
 Peaks_num.setText(String.valueOf(List_Of_Peaks));


 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="horizontal">


<TextView
        android:id="@+id/Peak_Num"
        android:layout_width="159dp"
        android:layout_height="wrap_content"
         android:background="@drawable/back"
        android:text="Peaks"
        android:textColor="#040307"
        android:layout_weight="1" />

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-12 14:36:53

代码语言:javascript
运行
复制
 List<Integer> List_Of_Peaks = findPeaks(String_TO_List);
 dialog.setTitle("my Dialog");
 dialog.setContentView(R.layout.customdialog);
 dialog.show();
 Log.i(TAG, "Peaks" + List_Of_Peaks);   
 Peaks_num = (TextView) dialog.findViewById(R.id.Peak_Num);
 String text="";
 for(Integer integer:List_Of_Peaks)
 {
      text+=integer+"\n"; // split
 }
 Peaks_num.setText(text);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34746272

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档