小编Spi*_*ike的帖子

如何获得彩色线来区分文本字段数组

我开发了一个框架,我使用GridBagLayout来安排12X12的文本字段.即框架上共有144个文本字段.现在我想在每个3列和3行之后用彩色线区分这些文本字段,如下图所示.我试过很多方面,但我找不到解决办法.请建议.下面是我的代码的一部分.提前致谢.

1 2 3 | 4 5 6 | 7 8 9 | 10 11 12
      |       |       |
1 2 3 | 4 5 6 | 7 8 9 | 10 11 12 
      |       |       |
1 2 3 | 4 5 6 | 7 8 9 | 10 11 12
-------------------------------    
1 2 3 | 4 5 6 | 7 8 9 | 10 11 12
      |       |       |
1 2 3 | 4 5 6 | 7 …
Run Code Online (Sandbox Code Playgroud)

java swing line jtextfield jseparator

2
推荐指数
1
解决办法
459
查看次数

如何在edittext中输入任何内容时避免异常?

我创建了edittexts,用户可以在其中输入数字.在我的应用程序,用户可以通过点击提交按钮提交值.(注:最初我将所有3个EditTexts为""用的setText()中的代码)提交我一直以下这些线路中的方法来检索值后.

String st1=editText1.getText().toString();
int tempVal1=Integer.parseInt(st);
String st2=editText2.getText().toString();
int tempVa2=Integer.parseInt(st);
String st3=editText2.getText().toString();
int tempVal3=Integer.parseInt(st);
Run Code Online (Sandbox Code Playgroud)

但在这里我的问题是,如果用户没有在第一EDITTEXT输入任何值和填充只有第二和第三并提交,然后在tempVal1的值应为0,但我得到异常监守,因为不是第一次声明有任何数据.如何避免此异常并在未填写相应edittext中的任何内容时保持tempVal 0?

我有一个疑问,当我添加这一 int x=Integer.valueOf(editText.getText());行时,我收到以下错误.为什么?The method valueOf(String) in the type Integer is not applicable for the arguments (Editable)

请澄清我的疑虑.

android exception android-edittext

1
推荐指数
1
解决办法
3238
查看次数