我有兩個選項卡的活動,其中一個選項卡具有可擴展列表視圖的片段。當滾動展開式列表視圖textview值更改
選中該選項卡後,將調用後臺操作並收集所有數據並將其設置在適當的數組中。
我可以看到可擴展的列表視圖和相關的孩子的,但是當我上下滾動時,我可以看到,該孩子的textview的值被改變。
on the base_expandable_adapter我正在與查看持有人爲組和孩子的。我無法弄清楚的是價值觀發生變化的原因。你有什麼可以解決這個問題嗎?
public class S_GRP_EXP_LST_ADAPTER extends BaseExpandableListAdapter{
private String TAG="EXP_LST_ADAPTER";
private Context CNTX;
private List<S_GRP_get_set>S_GRP_PARENT=new ArrayList<S_GRP_get_set>() ;
private HashMap<String, List<S_GRP_get_set_child>> listDataChildResult = new HashMap<String, List<S_GRP_get_set_child>>();
private ViewHolder holder=new ViewHolder();
public S_GRP_EXP_LST_ADAPTER(List<S_GRP_get_set> _S_GRP_PARENT,HashMap<String, List<S_GRP_get_set_child>> _listDataChildResult,Context _CNTX)
{
this.S_GRP_PARENT=_S_GRP_PARENT;
this.listDataChildResult=_listDataChildResult;
this.CNTX=_CNTX;
Log.i(TAG, ""+S_GRP_PARENT.size() + ""+ listDataChildResult.size());
}
@Override
public int getGroupCount() {
Log.i(TAG, "getGroupCount() invoked");
return S_GRP_PARENT.size();
}
@Override
public int getChildrenCount(int groupPosition) {
Log.i(TAG, "getChildrenCount() invoked");
return listDataChildResult.get(S_GRP_PARENT.get(groupPosition).Get_Group_Name()).size();
}
@Override
public Object getGroup(int groupPosition) {
Log.i(TAG, "getGroup() invoked");
return S_GRP_PARENT.get(groupPosition);
}
@Override
public Object getChild(int groupPosition, int childPosition) {
Log.i(TAG, "getChild() invoked");
return listDataChildResult.get(S_GRP_PARENT.get(groupPosition).Get_Group_Name()).get(childPosition);
}
@Override
public long getGroupId(int groupPosition) {
Log.i(TAG, "getGroupId() invoked");
return groupPosition;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
Log.i(TAG, "getChildId() invoked");
return childPosition;
}
@Override
public boolean hasStableIds() {
Log.i(TAG, "hasStableIds() invoked");
return false;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
Log.i(TAG, "getGroupView() invoked");
View parentView =convertView;
LayoutInflater inflater = (LayoutInflater)this.CNTX.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
if(parentView==null)
{
parentView = inflater.inflate(R.layout.group_index_list_layout, parent, false);
holder.grp_name=(TextView)parentView.findViewById(R.id.tv_Grp_Name);
holder.grp_mtrc=(TextView)parentView.findViewById(R.id.tv_Grp_Mtrc);
holder.grp_health=(TextView)parentView.findViewById(R.id.tv_Grp_Health_Title);
parentView.setTag(holder);
}
else{
holder = (ViewHolder) parentView.getTag();
}
holder.grp_name.setText(S_GRP_PARENT.get(groupPosition).Get_Group_Name());
holder.grp_mtrc.setText(S_GRP_PARENT.get(groupPosition).Get_Group_mtrc());
holder.grp_name.setText(S_GRP_PARENT.get(groupPosition).Get_Group_Name());
return parentView;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
Log.i(TAG, "getChildView() invoked");
View childView=convertView;
LayoutInflater inflaterchild = (LayoutInflater)this.CNTX.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
if(childView==null)
{
childView = inflaterchild.inflate(R.layout.group_exp_list_child_layout, parent, false);
child_holder.grp_r_index=(TextView)childView.findViewById(R.id.tv_r_S_name_in_GRP);
child_holder.grp_r_state=(TextView)childView.findViewById(R.id.tv_R_SRV_state);
childView.setTag(holder);
}
else
{
holder=(ViewHolder) childView.getTag();
}
child_holder.grp_r_index.setText(listDataChildResult.get(S_GRP_PARENT.get(groupPosition).Get_Grp_Name()).get(childPosition).get_srv_index());
child_holder.grp_r_state.setText(listDataChildResult.get(S_GRP_PARENT.get(groupPosition).Get_Grp_Name()).get(childPosition).get_srv_state());
return childView;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
//class for the view holder
public class ViewHolder
{
TextView grp_name;
TextView grp_mtrc;
TextView grp_health;
TextView grp_r_index;
TextView grp_r_state;
}
}
,您在服務器移植ListView?如果是那樣的靜態或動態數據。因爲listview刷新滾動 – chain
你能告訴我們你的代碼嗎? –
嗨,流程如下:1.從設備中獲取信息2.將所有信息放入數組3.將列表適配器,傳遞列表和散列表作爲參數調用。我會在短時間內分享代碼 – user2145673