2017-06-11 5 views
-1

目覚まし時計を作成していますので、グループの親をクリックして拡大可能リストビューを表示したいのですが、グループをクリックしても何も起こりません。さらに、getchildrencountのような子メソッドは動作しません。デバッグで知ることができます。 私のファイルはここにあります。私のグループビューは動作しているか可視です。BaseExpandable ListAdapterでChlidメソッドが機能していません

アダプタファイル:

public ExpandableAdapter(Context ctx, ArrayList<ParentBean> parentlist, 
ArrayList<ChildBean> childlist){ 

    this.ctx = ctx; 
    this.parentlist = parentlist; 
    this.childlist = childlist; 
    map = new HashMap<>(); 
    for(ParentBean pb : parentlist){ 
     ; 

    map.put(pb,childlist); 
    Log.e("childliset",String.valueOf(childlist.size())); 
}} 
@Override 
public int getGroupCount() { 
    Log.d("problem","1"); 
    for(ParentBean b : parentlist){ 
     Log.e("parentlist",b.toString()); 
    } 

    return parentlist.size(); 
} 

@Override 
public int getChildrenCount(int groupPosition) { 
    Log.e("problem", "30"); 
    Log.e("childlist",String.valueOf(childlist.size())); 

    return map.get(groupPosition).size(); 
} 

@Override 
public Object getGroup(int groupPosition) { 
    Log.e("problem2 ", parentlist.get(groupPosition).toString()); 
    Log.e("groupPosition",String.valueOf(groupPosition)); 
    return parentlist.get(groupPosition); 
} 

@Override 
public Object getChild(int groupPosition, int childPosition) { 
    Log.e("problem3",childlist.get(childPosition).toString()); 
    return childlist.get(childPosition); 
} 

@Override 
public long getGroupId(int groupPosition) { 
    Log.e("problem4",String.valueOf(groupPosition)); 
    return groupPosition; 
} 

@Override 
public long getChildId(int groupPosition, int childPosition) { 
    Log.e("problem4",String.valueOf(childPosition)); 
    return childPosition; 
} 

@Override 
public boolean hasStableIds() { 
    return false; 
} 

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

    ParentBean header = (ParentBean) this.getGroup(groupPosition); 

     if(convertView == null){ 
      LayoutInflater inflater = (LayoutInflater) 
this.ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      convertView = inflater.inflate(R.layout.parent_view,null); 
     } 
     Log.e("Mision2",header.toString()); 
     TextView alarm_time = 
    (TextView)convertView.findViewById(R.id.alarm_time); 
    if(header.getHour()>=12){ 
     header.setHour(header.getHour()-12); 
    }if(header.getHour()<10){ 
     alarm_time.setText("0"+header.getHour()+" : "+header.getMinute()); 
    }else{ 
    alarm_time.setText("0"+header.getHour()+" : "+header.getMinute());} 

    TextView date = (TextView)convertView.findViewById(R.id.date); 
    if(header.getDate()<10){ 
     date.setText("0"+header.getMonth()+"-"+header.getDate()+"- 
    "+header.getMinute()); 
    }else { 
     date.setText(header.getMonth() + "-" + header.getDate() + "-" + 
header.getMinute()); 
    } 



    Log.e("mission ", "possible"); 
    return convertView; 
} 

@Override 
    public View getChildView(int groupPosition, int childPosition, boolean 
isLastChild, View convertView, ViewGroup parent) { 

    Log.e("mission","impossible"); 
    ChildBean footer = 
(ChildBean)this.getChild(groupPosition,childPosition); 
    if (convertView==null){ 
     LayoutInflater inflater = 
(LayoutInflater)this.ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
     convertView = inflater.inflate(R.layout.child_view,parent,false); 

    } 







    return convertView; 
} 

XMLファイルの子ビュー:上記の質問の答えを探している

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" android:layout_width="match_parent" 
    android:layout_height="match_parent"> 


    <CheckBox 
    android:id="@+id/checkBox" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="13dp" 
    android:layout_alignParentTop="true" 
    android:layout_toRightOf="@+id/song_name" 
    android:layout_toEndOf="@+id/song_name" 
    android:layout_marginLeft="41dp" 
    android:layout_marginStart="41dp" /> 

    <TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="16dp" 
    android:text=" Song: " 
    android:layout_marginLeft="11dp" 
    android:layout_marginStart="11dp" 
    android:layout_alignBottom="@+id/song_name" 
    android:layout_toRightOf="@+id/imageView" 
    android:layout_toEndOf="@+id/imageView" /> 

    <ImageView 
    android:id="@+id/imageView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="20dp" 
    android:layout_marginStart="20dp" 
    app:srcCompat="@drawable/song_icon" 
    android:layout_alignBottom="@+id/textView2" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" /> 

    <TextView 
    android:id="@+id/song_name" 
    android:layout_width="80dp" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="12dp" 
    android:layout_marginStart="12dp" 
    android:textSize="16dp" 
    android:text="TextView" 
    android:layout_alignBaseline="@+id/checkBox" 
    android:layout_alignBottom="@+id/checkBox" 
    android:layout_toRightOf="@+id/textView2" 
    android:layout_toEndOf="@+id/textView2" /> 

    <TextView 
    android:id="@+id/textView4" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Vibrate" 
    android:textSize="16dp" 
    android:layout_alignLeft="@+id/checkBox" 
    android:layout_alignStart="@+id/checkBox" 
    android:layout_marginLeft="41dp" 
    android:layout_marginStart="41dp" 
    android:layout_alignTop="@+id/song_name" /> 

<ImageButton 
    android:id="@+id/imageButton" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    app:srcCompat="@drawable/delete" 
    android:layout_marginTop="11dp" 
    android:layout_below="@+id/checkBox" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_marginLeft="13dp" 
    android:layout_marginStart="13dp" /> 

    <TextView 
    android:id="@+id/textView5" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignTop="@+id/imageButton" 
    android:layout_marginLeft="10dp" 
    android:layout_marginStart="10dp" 
    android:layout_marginTop="11dp" 
    android:textSize="16dp" 
    android:layout_toEndOf="@+id/imageButton" 
    android:layout_toRightOf="@+id/imageButton" 
    android:text="Delete" /> 
    </RelativeLayout> 

答えて

0

みんな。 実際には、グループビューをクリックすると子メソッドが機能します。 parent_view.xml

の私の親のレイアウトにdescendantFocusability = "blocksDescendants"

をこの文:私は

アンドロイドを追加する必要があります私の場合は