微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何在运行时在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 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?