android - 使用变量字符串的 Textview 声明
问题描述
是否可以声明许多不同的 TextView。像 tv_concept1、tv_concept2、tv_concept3……等等。使用可变字符串?如果字符串为“1”,它将声明 tv_concept1。所以它会将 tv_concept1 文本更改为 Hi。但如果变量是 2,那么其他 TextView 会这样做。
String textview = "tv_concept" + value;
TextView textview = findViewById(R.id.textview);
textview.setText("Hi");```
解决方案
您可以使用对象数组。
推荐阅读
- google-bigquery - 使用另一个表生成 CASE WHEN 语句
- ios - Azure AD B2C 的 iOS 14 问题
- excel - VBA 在 word 中查找和替换。用数字和单词之间的不间断空格替换空格
- sql - EF Core 插入操作 - SQL 命令如何工作?
- json - 当值为整数时,不能将小数部分显示为 .0
- nix - 在 nix 包中设置标志
- angular - 如何使用数据从另一个网站重定向到 Angular 应用程序?
- python - 如何使 admin.TabularInline 中的字段之一成为条件?
- android - Google 登录 OAuth、后端服务器身份验证和令牌每日限制
- c - 如何对我的随机生成器函数进行单元测试?