标签: expandablelistview

ExpandableListView - 隐藏没有子项的组的指示符

在一个ExpandableListView,有没有办法隐藏没有孩子的群组指标?

android expandablelistview android-listview

104
推荐指数
7
解决办法
9万
查看次数

展开可扩展列表视图中的所有子项

我想在填充可扩展列表视图时展开所有子项.目前我的代码如下所示:

ExpandableListView listView = (ExpandableListView) findViewById(R.id.view);
int count = viewAdapted.getGroupCount();
for (int position = 1; position <= count; position++)
    listView.expandGroup(position - 1);
Run Code Online (Sandbox Code Playgroud)

这很难看.有没有更好的方法来做到这一点?

android expandablelistview

72
推荐指数
4
解决办法
6万
查看次数

如何完全隐藏ExpandableListView的groupIndicator?

我想在自定义的ExpandableListView中完全隐藏groupIndicator.

这里提供的示例似乎不起作用.

它建议制作一个选择器并使用我复制的expList.setGroupIndicator(selector):

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/empty_icon">
    <item android:state_empty="true" android:drawable="@android:color/transparent"/>
    <item android:state_expanded="true" android:drawable="@android:color/transparent" />
    <item android:drawable="@android:color/transparent" />
</selector>
Run Code Online (Sandbox Code Playgroud)

这会产生以下错误
ERROR/AndroidRuntime(10675): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x12/d=0x0 a=2 r=0x7f0b0013}

类似的建议使用android:id/empty代替颜色/透明.

如何完全隐藏群组指标?

编辑:事实证明,该代码可以工作...如果你把它放在drawable资源文件夹而不是布局.

android expandablelistview

68
推荐指数
1
解决办法
3万
查看次数

可扩展列表视图将组图标指示器移动到右侧

关于可扩展列表视图,组图标指示器位于左侧,我可以移动指示器并将其定位在右侧吗?谢谢.

编辑:由于我不想扩展视图,我得到了动态获取宽度的解决方法.只是分享我的解决方案

Display newDisplay = getWindowManager().getDefaultDisplay(); 
int width = newDisplay.getWidth();
newListView.setIndicatorBounds(width-50, width);

android indicator expandablelistview

63
推荐指数
6
解决办法
7万
查看次数

在expandable listview android中折叠除选定组之外的所有组

我正在使用可扩展列表视图开发android应用程序.其实我需要的是,我正在列出包含孩子的群组.

如果我选择一个不可扩展的组,它应该展开,在我选择第二组后,第一组应该折叠.我做谷歌,但我找不到我想要的东西.请帮帮我.

expand android expandablelistview collapse

61
推荐指数
4
解决办法
5万
查看次数

ExpandableListView -UnsupportedOperationException:AdapterView不支持addView(View,LayoutParams)

我在android中实现Expandable List视图,我得到了上面标题的错误.请帮我.

主要活动是 -

package com.expand;

import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.Toast;


public class MyExpandableListViewActivity extends Activity {
    /** Called when the activity is first created. */



    static final String groupElements[]= {
           "India",
           "Australia",
           "England",
           "South Africa"
         };

    static final String[][] childElements=
    {
           {
          "Sachin Tendulkar",
          "Raina",
          "Dhoni",
          "Yuvi"
           },
           {
          "Ponting",
          "Adam Gilchrist",
          "Michael Clarke"
           },
           {
          "Andrew Strauss",
          "kevin Peterson",
          "Nasser Hussain"
           },
           {
          "Graeme Smith",
          "AB de villiers",
          "Jacques …
Run Code Online (Sandbox Code Playgroud)

android expandablelistview android-adapterview

59
推荐指数
2
解决办法
3万
查看次数

以编程方式折叠ExpandableListView中的组

当我扩展一个新组时,我可以将最后一个扩展掉吗?

android expandablelistview

56
推荐指数
3
解决办法
4万
查看次数

Android ExpandableListView - 寻找教程

我正在尝试编写一个Android界面,它在侧面使用可扩展列表,在另一侧使用片段,因此我可以通过单击可扩展列表的子项来加载不同的资源.但不幸的是,我无法在任何地方找到关于此列表的任何好的教程.是的,我查看了API演示,并且我已经使用BaseExpandableListAdapter创建了一个普通的列表,但仍然理解这些列表,如果没有一个好的教程,它有点难,你有什么好的或我可以检查的信息吗?

android expandablelistview

48
推荐指数
2
解决办法
9万
查看次数

在ExpandableListView中更改可扩展指示器

我正在尝试创建一个ExpandableListView.群组的初始视图显示正常.但是,当我单击列表项时,我的箭头不会更改.见下图.

在此输入图像描述

如何更改箭头的方向?

我有布局XML:

  <ExpandableListView
        android:id="@+id/expandable_list"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"            
        android:divider="@null"
        android:background="#ffffff"
        android:groupIndicator="@drawable/settings_selector"
        android:transcriptMode="alwaysScroll" />
Run Code Online (Sandbox Code Playgroud)

settings_selector.xml:

 <?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >

<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:drawable="@drawable/arrow_down"
        android:state_empty="true"/>
    <item
        android:drawable="@drawable/arrow_right"
        android:state_expanded="true"/>
</selector>

</animation-list>
Run Code Online (Sandbox Code Playgroud)

android listview expandablelistview

46
推荐指数
3
解决办法
9万
查看次数

Android:向ExpandableListView添加标题视图时的ClassCastException

我正在尝试向ExpandableListView添加标头,如下所示:

headerView = View.inflate(this, R.layout.header, null);
expandableListView.addHeaderView(headerView);
expandableListView.setAdapter(new SectionedAdapter(this));
Run Code Online (Sandbox Code Playgroud)

这给了我以下错误:

 12-08 16:23:42.354:
 ERROR/AndroidRuntime(421): Caused by:java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams
 12-08 16:23:42.354:   ERROR/AndroidRuntime(421): at android.widget.ListView.clearRecycledState(ListView.java:504)
 12-08 16:23:42.354: ERROR/AndroidRuntime(421): at android.widget.ListView.resetList(ListView.java:490)
 12-08 16:23:42.354:ERROR/AndroidRuntime(421):at android.widget.ListView.setAdapter(ListView.java:422)
 12-08 16:23:42.354:ERROR/AndroidRuntime(421): at android.widget.ExpandableListView.setAdapter(ExpandableListView.java:475)
Run Code Online (Sandbox Code Playgroud)

这是在电话会议上发生的expandableListView.setAdapter(new SectionedAdapter(this)),但我无法弄清楚原因.有任何想法吗?

android classcastexception expandablelistview android-linearlayout

44
推荐指数
2
解决办法
2万
查看次数