如何在运行时在expandablelistActivity中设置setText?

问题描述

| 这是我在运行时在kist视图中尝试设置setText的代码,但是当我尝试扩展新的父对象时,它会更改。 下面是我的代码
SimpleExpandableListAdapter expListAdapter = new SimpleExpandableListAdapter(
    this,createGroupList(),// groupData describes the first-level
                         // entries
    R.layout.catagory_group_row,// Layout for the first-level
                                 // entries
    new String[] { \"catagoriesName\" },// Key in the groupData maps
                                       // to display
    new int[] { R.id.childname },// Data under \"catagoriesName\" key
                                  // goes into this TextView
    createChildList(),// childData describes second-level entries
    R.layout.catagory_child_row,// Layout for second-level entries
    new String[] { \"ItemsName\",\"desc\" },// Keys in childData maps
                                          // to display
    new int[] { R.id.menu,R.id.quantity } // Data under the keys
                                           // above go into these
                                           // TextViews
    );

    Log.i(LOG_TAG,\"inside ExpandableList\");
    setListAdapter(expListAdapter);
}

public boolean isChildSelectable(int groupPosition,int childPosition) {
    return true;
}

// Update the current state if changed
@Override
public void onContentChanged() {
    super.onContentChanged();
    Log.d(LOG_TAG,\"onContentChanged\");
}

@Override
public boolean onChildClick(ExpandableListView parent,View v,int groupPosition,int childPosition,long id) {

    Log.d(LOG_TAG,\"onChildClick: \" + childPosition);
    // final TextView text1 = (TextView) parent.
    // TextView textView=new TextView(Format.this);
    // parent.getItemAtPosition(childPosition);
    int i = childPosition;
    text = (TextView) v.findViewById(R.id.quantity);
    CheckBox cb = (CheckBox) v.findViewById(R.id.check1);
    tvMenuName = (TextView) v.findViewById(R.id.menu);
    tvDescName = (TextView) v.findViewById(R.id.desc);

    /*
     * Show DialogBox for Enter User Input
     */

    final AlertDialog.Builder alert = new AlertDialog.Builder(this);
    final EditText input = new EditText(this);
    alert.setTitle(\"Enter Items Number to be Order\");
    alert.setView(input);

    alert.setPositiveButton(\"Ok\",new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog,int whichButton) {
            String value = input.getText().toString().trim();

            // text1.setText(value);
            // qty = value;

            try {
                String[] val = value.split(\"/\");
                int quantity = Integer.parseInt(val[0]);
                tvDescName.setText(value);
                OrderlistData data = new OrderlistData(tvMenuName.getText()
                        .toString(),value);
                orderlist.add(data);
                // qty=\"\";
            } catch (Exception e) {
                System.out.println(\"enter a valid quantity\");
            }

        }
    });

    alert.setNegativeButton(\"Cancel\",new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog,int whichButton) {
                    dialog.cancel();
                }
            });

    /**
     * Getting Orderlist Data from Customer
     */

    alert.show();

    // return(true);
    if (cb != null) {
        cb.toggle();
        /*
         * if(tvDescName.getText()!=\"\") cb.setChecked(true); else
         * cb.setChecked(false);
         */
    }

    return true;

}
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...