- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我的代码。升当我运行它时,模拟器屏幕上什么也没有。即使我正在为父组传递值。
我也在 getGroupView 上设置了断点,但是这个方法没有被调用。
//父组中值的类
public class ArrayForList
{
public static String[] grp ={"Car"};
}
//Activity
public class ExpandableActivity extends Activity {
ExpandableListView ev;
ExpandableAdapter adp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_expandable);
ev = (ExpandableListView) findViewById(R.id.el);
ev.setAdapter(new ExpandableAdapter(this));
}
}
//适配器
public class ExpandableAdapter extends BaseExpandableListAdapter {
Context myContext;
public ExpandableAdapter(Context con)
{
this.myContext = con;
}
@Override
public Object getChild(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getChildrenCount(int groupPosition) {
// TODO Auto-generated method stub
return 0;
}
@Override
public Object getGroup(int groupPosition) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getGroupCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public long getGroupId(int groupPosition) {
// TODO Auto-generated method stub
return groupPosition;
}
@Override
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.tv_group);
tvGroupName.setText(ArrayForList.grp[groupPosition]);
return convertView;
}
@Override
public boolean hasStableIds() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return false;
}
}
//xml group_row
<TextView
android:id="@+id/tv_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
//xml主体
<ExpandableListView
android:id="@+id/el"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
最佳答案
在 ExpandableAdapter 类中更改某些方法的返回值。例如 getGroupCount() 返回大小 0,它更改为组大小。 getGroup(int groupPosition),同样返回空值,改变组在 groupPosition 的值。
关于android - 为什么 getGroupView 没有调用 ExpandableListView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16140204/
我正在编写一个利用 ExpandableListView 功能的 Android 应用程序,由于某种原因,我似乎无法填充 View 。我最初使用的是常规的 ListView,它填充了正确的信息。然后,
我正在制作一个使用 ListView 和列表适配器的应用程序。它工作正常,但我在 getgroupview 方法中发现了内存泄漏。在我每次都膨胀 xml 文件并导致泄漏之前。 groupRow =
这是我的代码。升当我运行它时,模拟器屏幕上什么也没有。即使我正在为父组传递值。 我也在 getGroupView 上设置了断点,但是这个方法没有被调用。 //父组中值的类 public class A
我有一个包含 2 个页面的 Viewpager,在第 1 页我填写了一个表单并滑动到第 2 页,其中包含 expandableList,我正在使用如下自定义适配器. 我在布局中包含了可扩展的 list
我在 Android 中使用 ExpandableListView。 我有一个对话框使这个 View 膨胀: 对于 getgroupview() 方法,我的 BaseExpandab
我有一个虚拟 JSON 数据,它有一个大小为 8 的 ArrayList。它们必须填充在 expandableListView 中,但它只显示第一组。因为当我调试它时,getGroupView 总是在
我是一名优秀的程序员,十分优秀!