Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
xmlのみで正または負の数に基づいてテキストビューの色を記述するオプションがあるかどうかを知りたいです。xmlで不可能な場合は、コードで数値を正から負に変更し、その逆を何度も繰り返し、アプリの起動時点で色が残っているため、Javaでそれを行うにはどうすればよいですか?
このように:(myTVがあなたのものですTextView)
TextView
int number = Integer.parseInt(myTV.getText()); if(number<0){ myTV.setTextColor(getResources().getColor(R.color.negativeColor)); } else{ myTV.setTextColor(getResources().getColor(R.color.positiveColor)); }
XMLでこれを行う方法はありません...