我是一个全新的Android Studio与Java,我只熟悉HTML,CSS,JavaScript和PHP。
我正在构建一个应用程序,我需要它从一个数组中生成一个项目列表。我该怎么做?
我试着简单地这样做,但在活动中什么也没有显示!
public void run(){
TextView t = new TextView(viewAuto.this);
t.setTextColor(Color.RED);
字符串
“); }
我是一个全新的Android Studio与Java,我只熟悉HTML,CSS,JavaScript和PHP。
我正在构建一个应用程序,我需要它从一个数组中生成一个项目列表。我该怎么做?
我试着简单地这样做,但在活动中什么也没有显示!
public void run(){
TextView t = new TextView(viewAuto.this);
t.setTextColor(Color.RED);
字符串
“); }
2条答案
按热度按时间mbyulnm01#
在Android中,在第一步中,您将调色板的每个功能放在xml中,您必须在java文件中像这样标识它
TextView textView = findViewById(R.id.textView);
然后你就可以应用这些变化了。你所做的是从textView创建一个对象,这在材质设计的情况下是错误的。相反,它适用于类、片段、适配器等。
lztngnrs2#
您需要首先创建XML布局和创建TextView组件
字符串
然后你去编码并获得文本视图,并使用\n附加所有字符串,以便在每个字符串的末尾都转到新行
型
为了在可滚动列表中显示项目,您需要使用
ScrollView
,为了获得更好的性能,您需要使用RecyclerView