1

すでに作成した展開可能なリストビューを取得して、グループのリストにあるアイテムの1つの背景の色を変更しようとしています。ドロップダウンの子ではなく、メインリストのエントリの色を変更したいだけです。これは、クリックして他の部分を展開または非表示にする部分です。getGroupViewがこれを行うと思いますが、これを機能させる方法がわかりません。これが適切な使用方法である場合、誰かがそれを使用する方法を説明できますか?より良い方法があるとしたら、それは何ですか?

[編集]もう少し遊んで、getGroupViewの使い方を少し理解しましたが、まだ問題があります。私が理解するために行っているのは、1つのエントリの色を変更するだけで、代わりにすべてのエントリを変更することです。コードは次のとおりです。

    View listViewRow = findViewById(R.layout.menu_item);
    listViewRow = myNewAdapter.getGroupView(2, false, listViewRow, expandView);
    listViewRow.setBackgroundColor(Color.RED);

ここで、menu_itemは、展開可能なリストのグループに使用しているレイアウトファイルの名前であり、expandViewはexpandableListViewです。

4

3 に答える 3

0

拡張BaseExpandableListAdapterクラスでこれを試してください

public View getGroupView(int groupPosition, boolean isExpanded,
    View convertView, ViewGroup parent) {

   if (convertView == null) {
    LayoutInflater inflater =  (LayoutInflater) myContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    convertView = inflater.inflate(R.layout.group_row, null);
   }

   TextView tvGroupName = (TextView) convertView.findViewById(R.id.tvGroupName);
   tvGroupName.setText(list.get(groupPosition).getYear() +" COLLECTION");

   return convertView;
  }

またはこれを参照してください

于 2012-11-02T05:12:04.117 に答える
0

これを試して

  • ヘッダーリストの色を変更したい場合は、headerlist.xmlを変更してください

     <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:padding="8dp"
      android:orientation="vertical"
     android:background="@color/colorRed">
    </LinearLayout>
    

    -childlist.xmlでchildlistの色を変更したい場合

     <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
      android:layout_height="55dip"
    
     android:layout_marginLeft="@dimen/_15dp"
    </RelativeLayout>
    
于 2017-05-23T10:40:41.747 に答える
-3

別の色を表示したい場所にこの行を配置します。

- android:textColor="#a60704"

次の代わりに任意の色を付けます。

- #a60704
于 2012-11-02T04:47:13.370 に答える