- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在 Android 中使用 ExpandableListView。
我有一个对话框使这个 View 膨胀:
<ExpandableListView
android:id="@+id/comments_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/editTextNewComment"
android:layout_alignParentLeft="true" >
</ExpandableListView>
<EditText
android:id="@+id/editTextNewComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/imageButtonPostNewComment"
android:ems="10"
android:singleLine="true" >
<requestFocus />
</EditText>
对于 getgroupview() 方法,我的 BaseExpandableListAdapter 看起来像这样:
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
ViewGroup parent) {
View row = convertView;
ViewHolder holder = null;
Log.d("LIST", "getGroupView() groupPosition " + groupPosition + " isExpanded " + isExpanded + " row " + row);
if(row==null) {
LayoutInflater infl = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = infl.inflate(R.layout.list_item_comment,parent,false);
holder = new ViewHolder(row);
holder.imbutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Integer pos = (Integer) v.getTag();
//Do something
}
});
row.setTag(holder);
}
else {
holder = (ViewHolder) row.getTag();
}
holder.imbutton.setTag(Integer.valueOf(groupPosition));
holder.header.setText(""+ (groupPosition+1) + " - " + comments[groupPosition].getOwner());
//.... etc - setting all the textviews accordingly
return row;
}
我的问题:
当我在我的 edittext 中写东西时,getgroupview 总是被调用!这是日志的输出,仅在编辑文本中添加一个字母:
03-15 14:07:51.072: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.080: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.088: D/LIST(4176): getChildView()
03-15 14:07:51.096: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.104: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.111: D/LIST(4176): getChildView()
03-15 14:07:51.119: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.119: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.127: D/LIST(4176): getChildView()
03-15 14:07:51.135: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.135: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.143: D/LIST(4176): getChildView()
03-15 14:07:51.151: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.151: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.158: D/LIST(4176): getChildView()
03-15 14:07:51.205: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.205: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.213: D/LIST(4176): getChildView()
03-15 14:07:51.213: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.213: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.221: D/LIST(4176): getChildView()
03-15 14:07:51.221: D/LIST(4176): getGroupView() groupPosition 0 isExpanded false row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.221: D/LIST(4176): getGroupView() groupPosition 1 isExpanded true row android.widget.RelativeLayout{41a17d98 V.E..... ......I. 0,0-0,0}
03-15 14:07:51.229: D/LIST(4176): getChildView()
对于输入的每个字母,getGroupView() 和 getChildView() 被调用多次。在上面的示例中, ListView 显然被重绘了八次(我在该示例的列表中有 2 个组 View 和一个 subview 。)
我错过了什么?当我在编辑文本中输入内容时,甚至不需要重新绘制 ListView 。即使正在重绘,为什么会有八次调用不同的 getview 方法?
编辑:我现在看到,即使当我折叠和/或展开组 View 时,也有大量调用 getgroupview 和 getchildview 方法。这是应该的样子吗?
编辑2:现在在正常 Activity 中使用带有 edittext 的列表进行了一些测试,看起来列表没有那么频繁地重新绘制。所以问题似乎在于我在对话框中展示了这个。不明白为什么它甚至需要重新绘制。
最佳答案
您永远无法知道何时调用 getView
方法(对于 getGroupView
也是如此)以及调用了多少次。
但我确实看到了一些可以使其调用超出需要的东西:在您的布局中,您将 ExpandableListView
高度设置为 wrap_content。我不认为这是一件好事:
你让他需要重新绘制它的子元素以了解它的大小以适应它的内容,而它不需要包装它的内容,因为它是一个可滚动的布局。
尝试将其设置为 0dip
,使用 layout_weight="1"
以便为 TextView 留出空间:
<ExpandableListView
android:id="@+id/comments_list"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:layout_above="@+id/editTextNewComment"
android:layout_alignParentLeft="true" >
</ExpandableListView>
关于android - 当我在 EditText 中编辑数据时,BaseExpandableListAdapter 调用 getgroupview(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15433456/
我添加了编辑按钮 self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButto
我试图在运行时“干净地”更改 UIBarButtonItem 文本,以便可以切换编辑/完成模式。然而,每次我在运行时更改 title 属性时,动画看起来都很笨拙。我正在寻找模拟联系人应用程序中“编辑/
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
我想更改 INI 文件中的一些值。不幸的是,我在 2 个不同的部分有键,它们共享相同的名称但需要不同的值。我的代码使用 Get-IniContent函数来自 PsIni . 示例 INI 文件: [P
是否有通知或委托(delegate)方法可用于检测表格 View 何时进入编辑状态? 我想要做的是检测表正在编辑,然后显示一个额外的行,上面写着“添加新项目”或类似的东西。 我尝试在加载 View C
例如,我试图从 svg 读取样式块,我可以获取类型但不能获取字符串。 $svgTemplate = new SimpleXMLElement($_POST['SvgTemplateImport']);
我可以使用 self.navigationItem.leftBarButtonItem = self.editButtonItem; 通过按下导航面板上的编辑按钮让 UITableViewContro
我正在使用markitup!作为 Markdown 编辑器( example )。 目前,我需要按预览按钮(绿色勾号)来显示预览面板。 我希望自动显示预览 - 我怎样才能实现这一点? 最佳答案 我没有
我的处境非常糟糕。我丢失了源代码,客户需要在应用程序中进行一些更改。想想一个编辑程序集的例子:Test.dll,然后添加代码行,最后重新编译它 所以我的问题是: -可以这样做吗? -如果可能的话,什么
我使用了一些 JavaScript 来通过按钮更改段落元素的内容。它工作正常,但我还想让按钮控制标题和附图。给我指明正确的方向吗? 这是我用来更改段落的代码 .... 谢谢! 最佳答案 尝试将 Ja
是否有任何 Emacs lisp 插件可以让我轻松地在 yaml 文件中编辑或输入数据。 例如: --- sample yaml file ---Name : Addr :City :State:Zi
新手Java问题,我确定已经解决了,但是在任何地方都找不到解决方案:( 我想使用这里包含的java程序http://sourceforge.net/projects/ant-tibco/files/
在我的网页中,我使用了 gridview。在这个 GridView 中,它显示了一组用户信息。我刚刚从智能标签菜单中添加了一个按钮。我的要求是当我点击每个用户对应的按钮时,它会重定向到另一个页面并显示
我想在没有任何框架的情况下直接在 JS 中编辑一个 SVG 文件。 基本上我有一个 SVG 主文件,其中应该包含一些子 SVG。 我已经在 Ajax 中检索了这些子项的内容,但我想将它们插入到 SVG
我有我的 ViewModel,我有我的 Controller 可以从 ViewModel 正确显示,但是我不确定如何使 ViewModel 可编辑,以便将编辑后的数据发送回模型。我只想编辑 Order
我不确定我的做法是否正确。 IplImage *dog_1 = cvCreateImage(cvGetSize(oriImg), oriImg->depth, oriImg->nChannels);
我有一个创建二维码的网络服务器。在此过程中,我得到一个 BarcodeQRCode 对象,我可以从中获取图像 (.getImage())。 我不确定如何将这张图片发回给客户。我不想将它保存在文件中,而
已编辑:我的第一个问题解决了,但又出现了另一个问题,只提供了一个用户 ID。这是修改后的代码的屏幕截图。 回到表格,用户将按下编辑按钮,这样他就可以编辑问题并给出适当的操作.. 我的上表代码是这样的:
据我了解,我无法通过重新启动服务器来清除 MySQL 查询缓存。 每次运行 sql 时,我都试图获得与第一个代码块类似的结果 1-这是在重新启动 Apache 和 MySQL 之前(第一次使用这些查询
我正在创建一个页面来搜索项目,然后能够编辑/更新它。当它只返回一个结果时我能够做到这一点,但当它给我多个结果时我只能编辑最后一项。下面是我的代码: ....... $dj =$_POST[djnum]
我是一名优秀的程序员,十分优秀!