2017-05-10 11 views
0

ここでは、ListViewの値の行の色を設定します。今、私はこれだけの文字列、ないすべての行に色を設定したいListViewでテキストの色を設定する方法

ListAdapter adapter = new SimpleAdapter(MainActivity.this, DevicesList, 
        R.layout.list_item, new String[]{"name", "clients", "stan"}, 
        new int[]{R.id.name, R.id.clients, enabled}){ 
       @Override 
       public View getView(int position, View convertView, ViewGroup parent) { 
        View view = super.getView(position, convertView, parent); 
        TextView v = (TextView) view.findViewById(R.id.enabled); 
        String a = v.getText().toString(); 

        if (a == "Aktywny") { 
         view.setBackgroundColor(Color.argb(125,53,104,45)); 
        } else if(a == "Nieaktywny") { 
         view.setBackgroundColor(Color.argb(125,175,43,30)); 
        } else{ 
         view.setBackgroundColor(Color.argb(125,139,140,122)); 
        } 

        return view; 
       } 
      }; 
+1

[AndroidのListViewコントロールのテキストの色](の可能性のある重複http://stackoverflow.com/questions/4533440/android-listview-text-color ) –

答えて

0
v.setTextColor(Color.argb(125,175,43,30)) 
+0

ありがとう – Torwopik

関連する問題