我正在开发 Android 项目。现在我必须创建自己的可扩展列表。这是我遵循的解决方案:
这就是生成我 TextView 的代码(它是列表中的元素)。我想创建类似 android.R.layout.simple_expandable_list_item 项的东西而不是这个 TextView。我的意思是在左边放一些图片,然后是文字。我怎么能这样做?
我尝试过使用 Button 并在 Button 上设置左图标,但没有帮助。按钮不会展开/折叠我的列表。
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
TextView tv = new TextView(Vincent_ThreeelevellistActivity.this);
tv.setText("->FirstLevel");
tv.setTextColor(Color.BLACK);
tv.setTextSize(20);
tv.setBackgroundColor(Color.BLUE);
tv.setPadding(10, 7, 7, 7);
return tv;
}