- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
滚动时我在可扩展 ListView 中遇到问题,edittext 值发生变化。我尝试将值存储在模态类中并在 View 创建时设置该值。但是 Edittext 值在滚动时发生变化。请提出任何解决方案。这是我的代码用于可扩展 ListView 。给我一些提示或我在这段代码中出错的地方。
下面是我在android studio的日志
11-04 14:31:59.826 3632-3632/com.codefuelindia.healthcircleordermgmt E/edittext:-: android.support.design.widget.TextInputEditText{48bc9e8 VFED..CL。 ......... 0,0-514,118 #7f080061 app:id/edtQty} Pos011-04 14:32:04.862 3632-3632/com.codefuelindia.healthcircleordermgmt E/edittext:-: android.support.design.widget.TextInputEditText{a67b858 VFED..CL。 ......... 0,0-514,118 #7f080061 app:id/edtQty} Pos411-04 14:32:04.911 3632-3632/com.codefuelindia.healthcircleordermgmt E/edittext:-: android.support.design.widget.TextInputEditText{48bc9e8 VFED..CL。 ......ID 0,0-514,118 #7f080061 app:id/edtQty} Pos511-04 14:32:04.932 3632-3632/com.codefuelindia.healthcircleordermgmt E/edittext:-: android.support.design.widget.TextInputEditText{39f8d9c VFED..CL。 ......... 0,0-514,118 #7f080061 app:id/edtQty} Pos611-04 14:32:05.681 3632-3632/com.codefuelindia.healthcircleordermgmt E/edittext:-: android.support.design.widget.TextInputEditText{d8d264 VFED..CL。 ......... 0,0-514,118 #7f080061 app:id/edtQty} Pos311-04 14:32:05.738 3632-3632/com.codefuelindia.healthcircleordermgmt E/edittext:-: android.support.design.widget.TextInputEditText{bd81fa0 VFED..CL。 ......... 0,0-514,118 #7f080061 app:id/edtQty} Pos211-04 14:32:05.815 3632-3632/com.codefuelindia.healthcircleordermgmt E/edittext:-: android.support.design.widget.TextInputEditText{39f8d9c VFED..CL。 ......... 0,0-514,118 #7f080061 app:id/edtQty} Pos111-04 14:32:05.879 3632-3632/com.codefuelindia.healthcircleordermgmt E/edittext:-: android.support.design.widget.TextInputEditText{48bc9e8 VFED..CL。 ......... 0,0-514,118 #7f080061 app:id/edtQty} Pos011-04 14:32:06.201 3632-3632/com.codefuelindia.healthcircleordermgmt E/edittext:-: android.support.design.widget.TextInputEditText{a67b858 VFED..CL。 ......... 0,0-514,118 #7f080061 app:id/edtQty} Pos411-04 14:32:06.235 3632-3632/com.codefuelindia.healthcircleordermgmt E/edittext:-: android.support.design.widget.TextInputEditText{39f8d9c VFED..CL。 ......... 0,0-514,118 #7f080061 app:id/edtQty} Pos511-04 14:32:06.289 3632-3632/com.codefuelindia.healthcircleordermgmt E/edittext:-: android.support.design.widget.TextInputEditText{48bc9e8 VFED..CL。 ......ID 0,0-514,118 #7f080061 app:id/edtQty} Pos6
edittext引用重复,如何解决?
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.content.Context;
import android.graphics.Typeface;
import android.support.design.widget.TextInputEditText;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
import com.codefuelindia.healthcircleordermgmt.R;
import com.codefuelindia.healthcircleordermgmt.model.CatMaster;
import com.codefuelindia.healthcircleordermgmt.model.ProChild;
public class ExpandableListAdapter extends BaseExpandableListAdapter {
private Context _context;
private ArrayList<CatMaster> _listDataHeader; // header titles
// child data in format of header title, child title
private HashMap<CatMaster, ArrayList<ProChild>> _listDataChild;
public ExpandableListAdapter(Context context, ArrayList<CatMaster> listDataHeader,
HashMap<CatMaster, ArrayList<ProChild>> listChildData) {
this._context = context;
this._listDataHeader = listDataHeader;
this._listDataChild = listChildData;
}
@Override
public Object getChild(int groupPosition, int childPosititon) {
return this._listDataChild.get(this._listDataHeader.get(groupPosition))
.get(childPosititon);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(final int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final ProChild childText = (ProChild) getChild(groupPosition, childPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
}
TextView txtListChild = (TextView) convertView
.findViewById(R.id.lblListItem);
TextView tvUnitPrice;
final TextInputEditText edtQty;
final TextView tvTotalPrice;
tvUnitPrice = (TextView) convertView.findViewById(R.id.tvUnitPrice);
edtQty = (TextInputEditText) convertView.findViewById(R.id.edtQty);
edtQty.setText();
tvTotalPrice = (TextView) convertView.findViewById(R.id.tvTotalPrice);
txtListChild.setText(childText.getName());
tvUnitPrice.setText(childText.getPrice());
edtQty.setText(childText.getQty());
edtQty.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
f(!TextUtils.isEmpty(charSequence.toString())){
childText.setQty(charSequence.toString());
final double total=Double.parseDouble(childText.getPrice())*Integer.parseInt(charSequence.toString());
tvTotalPrice.setText("Total: ".concat(String.valueOf(total)));
}
else {
tvTotalPrice.setText("");
}
}
@Override
public void afterTextChanged(Editable editable) {
}
});
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
return this._listDataChild.get(this._listDataHeader.get(groupPosition))
.size();
}
@Override
public Object getGroup(int groupPosition) {
return this._listDataHeader.get(groupPosition);
}
@Override
public int getGroupCount() {
return this._listDataHeader.size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
CatMaster headerTitle = (CatMaster) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_group, null);
}
TextView lblListHeader = (TextView) convertView
.findViewById(R.id.lblListHeader);
lblListHeader.setTypeface(null, Typeface.BOLD);
lblListHeader.setText(headerTitle.getCatName());
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
最佳答案
在对 onchildView() 进行调试和分析后,我找到了可行的解决方案。我已经为商店父 View 和 subview 创建了查看器
class ViewHolder {
//Log.e("text view",txtListChild.toString());
TextView lblListHeader;
HashMap<Integer, HashMap<Integer, View>> multiHash = new HashMap<>();
HashMap<Integer, View> innerHashMap;
public ViewHolder(View v) {
innerHashMap = new HashMap<>();
lblListHeader = v.
findViewById(R.id.lblListHeader);
}
public View getInnerView(int pos, int groupPos) {
return multiHash.get(groupPos).get(pos);
}
// lblListHeader.setTypeface(null, Typeface.BOLD);
// lblListHeader.setText(headerTitle.getCatName());
public void setInnerView(int pos, int groupPos, View innerView) {
innerHashMap.put(pos, innerView);
multiHash.put(groupPos, innerHashMap);
}
}
以及用于从 hashmap 存储和检索 View 的 setter 和 getter 方法。如果 View 为空,我将 View 设置为 hashmap,否则从我存储的 hashmap 中获取 View 。希望遇到此问题的其他开发人员得到帮助来自这个答案。祝你有美好的一天..
@覆盖
public View getChildView(final int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
final ProChild childText = (ProChild) getChild(groupPosition, childPosition);
View myConvertView = convertView;
// Log.e("quantity:- ",childText.getQty().concat(String.valueOf(childPosition)));
final TextInputEditText textInputEditText;
if (convertView == null || !isLastChild || childPosition==this._listDataChild.get(this._listDataHeader.get(groupPosition))
.size()-1) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
holder.setInnerView(childPosition, groupPosition, convertView);
TextInputEditText textInputEditText1 = convertView.findViewById(R.id.edtQty);
TextView tvUnitPrice = convertView.findViewById(R.id.tvUnitPrice);
final TextView tvTotalPrice = convertView.findViewById(R.id.tvTotalPrice);
final TextView tvHeader=convertView.findViewById(R.id.lblListItem);
tvHeader.setText(childText.getName());
textInputEditText1.setText(childText.getQty());
tvUnitPrice.setText(childText.getPrice());
tvTotalPrice.setText( String.valueOf(childText.getTotal()));
//holder.edtQty.setText(childText.getQty());
// edtQty.setText(_listDataChild.get(_listDataHeader.get(groupPosition)).get(childPosition).getQty());
textInputEditText1.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
//Log.e("child...",""+childPosition);
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
grandTotalOf = 0.0;
childText.setQty(editable.toString());
// _listDataChild.get(_listDataHeader.get(groupPosition)).get(childPosition).setQty(editable.toString());
if (!editable.toString().isEmpty() && !editable.toString().equals("0")) {
//final double total=Double.parseDouble();
final double total = Double.parseDouble(childText.getPrice()) * Integer.parseInt(editable.toString());
tvTotalPrice.setText("Total: ".concat(String.valueOf(total)));
childText.setTotal(total);
} else {
tvTotalPrice.setText("");
childText.setTotal(0);
grandTotal.setGrandTotal(0);
}
for(int i=0;i<_listDataHeader.size();i++){
for(int j=0;j<_listDataChild.get(_listDataHeader.get(i)).size();j++){
grandTotalOf=grandTotalOf + _listDataChild.get(_listDataHeader.get(i)).get(j).getTotal();
}
}
grandTotal.setGrandTotal(grandTotalOf);
}
});
return holder.getInnerView(childPosition, groupPosition);
} else {
convertView = holder.getInnerView(childPosition, groupPosition);
if (convertView == null) {
holder.setInnerView(childPosition, groupPosition, myConvertView);
convertView = holder.getInnerView(childPosition, groupPosition);
}
TextInputEditText textInputEditText1 = convertView.findViewById(R.id.edtQty);
TextView tvUnitPrice = convertView.findViewById(R.id.tvUnitPrice);
final TextView tvTotalPrice = convertView.findViewById(R.id.tvTotalPrice);
final TextView tvHeader=convertView.findViewById(R.id.lblListItem);
textInputEditText1.setText(childText.getQty());
tvUnitPrice.setText(childText.getPrice());
tvHeader.setText(childText.getName());
tvTotalPrice.setText( String.valueOf(childText.getTotal()));
edtQty.setText(_listDataChild.get(_listDataHeader.get(groupPosition)).get(childPosition).getQty());
textInputEditText1.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
//Log.e("child...",""+childPosition);
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
grandTotalOf=0.0;
childText.setQty(editable.toString());
// _listDataChild.get(_listDataHeader.get(groupPosition)).get(childPosition).setQty(editable.toString());
if (!editable.toString().isEmpty() && !editable.toString().equals("0")) {
//final double total=Double.parseDouble();
final double total = Double.parseDouble(childText.getPrice()) * Integer.parseInt(editable.toString());
tvTotalPrice.setText("Total: ".concat(String.valueOf(total)));
childText.setTotal(total);
grandTotal.setGrandTotal(total);
} else {
tvTotalPrice.setText("");
childText.setTotal(0);
grandTotal.setGrandTotal(0);
}
for(int i=0;i<_listDataHeader.size();i++){
for(int j=0;j<_listDataChild.get(_listDataHeader.get(i)).size();j++){
grandTotalOf=grandTotalOf + _listDataChild.get(_listDataHeader.get(i)).get(j).getTotal();
}
}
grandTotal.setGrandTotal(grandTotalOf);
}
});
return convertView;
}
}
关于android - 带有 EditText 的可扩展 ListView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47091018/
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 4 个月前关闭。 Improve
我已经为这个概念苦苦挣扎了一段时间。我正在尝试提出一种松散耦合的 Azure 组件设计,该设计可以使用队列和辅助角色完全可扩展,从而使项目出列并处理。我可以随意扩展工作角色,并且发布到队列从来都不是问
尝试在 android 中创建可扩展 ListView 。我希望每个组都扩展到一个预设的 XML 布局文件。例如。 A组{ 展开时显示 XML 文件 A:按钮、搜索栏、微调器等 } 乙组{ 展开时显示
在 android 可扩展 ListView 中,我需要显示子项,仅在按下展开折叠节点时..即;我不想让 children 按下可扩展 ListView 的行。我该如何完成? 问候,罗尼 最佳答案 我
我正在开发一个Android代码编辑器,但是当我对它应用语法突出显示时,它会变得很滞后,是否有任何方法可以对其进行优化? 这是我的代码: protected void onCreate(Bundle
我正在开发安卓应用程序。我发现下面的输出图像显示了以下问题。请帮我解决我的问题。 Xml file 输出截图- 最佳答案 使用 setIndicatorBounds。 开发链接:http://deve
最近我在尝试使用 android 的可扩展 ListView ,所以我四处搜索并偶然发现了这个 http://about-android.blogspot.com/2010/04/steps-to-i
在 Control.Exception 的文档中在 base 4.4.0.0 中有一个如何创建异常层次结构的示例。该示例展示了如何通过根据父异常声明 Exception 类的实例来捕获特定异常的概括。
我正在开发一个将显示一些可扩展列表的应用程序。事实上,有时该对象不会有任何子对象。所以我想在我的可扩展列表中仅显示具有子元素的元素。我尝试在 getGroupView 函数中放入 if ,如果该对象没
这是一个有点开放式的问题,但是,制作良好的可扩展 Electron 应用程序的好方法是什么? VSCode、Atom 和许多其他工具都支持扩展,但它们的代码库太大,我无法理解发生了什么。我对 Jupy
我和一些 friend 为 Facebook 编写了一款游戏,但没有过多考虑游戏的实际架构 - 想象一下当我们每月吸引超过 300,000 名独立玩家并且我们的服务器崩溃时我们的惊喜。 现在我们正在努
您好,我正在使用 Android Expandable listview 并在其中用不同的 View 膨胀 child 。我遇到的问题是,当我展开一个 View 然后打开另一个父 View 时,布局中
我的场景是,我有一个可扩展 ListView ,在列表中动态添加我和 child 。我的子布局就是这样。 当我点击相应项目的编辑按钮时,我打开对话框从用户那里获取输入,然后点击更新相应的详细信息更新到
我想使用 RecyclerView 创建项目列表,并希望在单击时展开特定项目(如电话列表)。我想在不使用任何库的情况下实现这一目标。谁能帮忙? 最佳答案 获取子数据列表作为数据集中父数据的成员。并且,
我使用 ExpandableListview ... 我能够将从 Web 服务检索到的值设置为子布局的单个 Textview。现在需要在 Web 服务的子布局中设置两个不同的 Textviews 值我
我的可扩展 ListView 的顺序似乎不正确。 这是我的数据提供者: public class DataProvider { public static HashMap> getInfo() {
所以我试图在我的可扩展列表的子项列表中创建一行,但它不起作用,这是我的布局:
我有一个需要自定义箭头的可扩展 ListView 。我尝试将 groupIndicator 设置为这样的选择器: 但是,出于某种原因,这会扭曲箭头的尺寸,请参见下文: 知道它们为
我正在尝试实现具有 2 种不同布局的 ExpandableListView,到目前为止,我花了一段时间才真正让 1 个 View 组使用一个布局,而其他 2 个 View 组使用另一个。到目前为止,外
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
我是一名优秀的程序员,十分优秀!