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