###前提・実現したいこと
ExpandableListViewで文字色を動的に変更したいと考えています。
現在、以下のようにSimpleExpandableListAdapterをオーバーライドして親のタイトルの文字色を変更させているのですが、変更するタイトルを条件で分岐させることは可能なのでしょうか。
例えばタイトルがAAAであれば赤に、BBBであれば青に。といった具合です。
可能か不可能かだけでも教えていただけると助かります。
###該当のソースコード
//アダプタークラス SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter( MainActivity.this, // 親 parentsList, android.R.layout.simple_expandable_list_item_1, new String[]{PARENT}, new int[]{android.R.id.text1}, // 子 childrenList, R.layout.child, new String[]{CHILD}, new int[]{R.id.text2}){ @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { final View itemRenderer = super.getGroupView(groupPosition, isExpanded, convertView, parent); final TextView tv1 = (TextView)itemRenderer.findViewById(android.R.id.text1); tv1.setTextColor(0xff0000ff); // 親のタイトルを青にする return itemRenderer; } };
###補足情報(言語/FW/ツール等のバージョンなど)
Android Studio 2.3.2
親のタイトルはアプリケーションの名前を取得して表示しています。
Map<String, Object> parentData = new HashMap<>(); parentData.put(PARENT, info.applicationInfo.loadLabel(pm)); parentsList.add(parentData);
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/07/27 06:13