I want to get input from edittext in an array which will be seperated by comma(,) and compare its values to multiple textviews and change their backgrounds.I used split command but its not working.I'm a newbie,thanks in advance. My code is:
enter code here
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView1 =(TextView)findViewById(R.id.textView1);
textView2 =(TextView)findViewById(R.id.textView2);
textView3 =(TextView)findViewById(R.id.textView3);
textView4 =(TextView)findViewById(R.id.textView4);
editText1 =(EditText)findViewById(R.id.editText1);
button1 =(Button)findViewById(R.id.button1);
String value = editText1.getText().toString();
String[] floatStrings = value.split(",");
int[] result = new int[floatStrings.length];
for (int i=0; i<5; i++)
{
result[i] = Integer.valueOf(floatStrings[i]);
}
{
if(result[1]<30)
{
textView1.setBackgroundColor(Color.BLUE);
}
else if(result[2]>45)
{
textView2.setBackgroundColor(Color.RED);
}
else if(result[3]==50)
{
textView3.setBackgroundColor(Color.DKGRAY);
}
}
return;
}
}