Java 数组中TextEdit中的参数不正确
对不起,我的英语不好。我用谷歌翻译。 我只是为android编写了一个游戏。 对于我的问题,我给我一个数组中的检查。 在这种情况下,它是显示的检查值。 然后,支票金额将显示在文本编辑中,并按“支付”按钮进行支付。 按下按钮时,在文本编辑期间支付输入的值。 但是,仅支付全部费用,不支付部分费用。 我的问题是,这不是交给编辑的文本。 只有传递的值才会从头开始显示。 为什么?我的错在哪里? 我用数字???标记了字符区域Java 数组中TextEdit中的参数不正确,java,android,arrays,xml,android-edittext,Java,Android,Arrays,Xml,Android Edittext,对不起,我的英语不好。我用谷歌翻译。 我只是为android编写了一个游戏。 对于我的问题,我给我一个数组中的检查。 在这种情况下,它是显示的检查值。 然后,支票金额将显示在文本编辑中,并按“支付”按钮进行支付。 按下按钮时,在文本编辑期间支付输入的值。 但是,仅支付全部费用,不支付部分费用。 我的问题是,这不是交给编辑的文本。 只有传递的值才会从头开始显示。 为什么?我的错在哪里? 我用数字???标记了字符区域 for (int i = 0; i < jArray.length();
for (int i = 0; i < jArray.length(); i++) {
JSONObject jObject = jArray.getJSONObject(i);
if(jObject.has("error")){
no_schecks.setVisibility(View.VISIBLE);
}else {
no_schecks.setVisibility(View.INVISIBLE);
final int scheckid = jObject.getInt("scheckid");
final String condition = jObject.getString("condition");
scheckx = new Scheck(condition, scheckid );
ll = (TableLayout) rootview.findViewById(R.id.displayLinear);
TableRow row = new TableRow(getActivity());
scheckLocalStore.storeScheckData(scheckx);
LayoutInflater inflater = getLayoutInflater(getArguments());
View theInflatedView = inflater.inflate(R.layout.activity_scheckx,
null);
TextView conditions = (TextView) theInflatedView.findViewById(R.id.condition);
conditions.setText(" " + scheckx.condition + " ₢ ");
conditions = new TextView(getActivity());
row.addView(conditions);
Log.i("info", "start?????????????????????????????");
EditText setconditions = (EditText) theInflatedView.findViewById(R.id.setcondition);
setconditions.setText(scheckx.condition);
setconditions = new EditText(getActivity());
row.addView(setconditions);
Log.i("info", "end?????????????????????????????");
Button btnSetCondition = (Button) theInflatedView.findViewById(R.id.btnSetCondition);
final String thisCondition = scheckx.condition;
final String thisId = Integer.toString(scheckx.scheckid);
final int thatId = scheckx.scheckid;
Log.i("info", "start?????????????????????????????");
//final String thatCondition = setconditions.getText().toString();
final String thatCondition = ((EditText) theInflatedView.findViewById(R.id.setcondition)).getText().toString();
Log.i("info", "end?????????????????????????????");
scheckLocalStore = new ScheckLocalStore(super.getActivity());
btnSetCondition.setId(btnSetCondition.getId());
btnSetCondition.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnSetCondition:
Log.i("info", "SCHECKKRAM " + thatCondition + " " + thisCondition);
Scheck scheck = new Scheck(uid, usersecu, thatId, thisCondition);
executeScheck(scheck, thatCondition, thisId);
//objFragment = new activity_bank_main();
break;
}
if(objFragment != null){
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.container, objFragment)
.commit();
}
}
});
//row.setLayoutParams(TableRow.LayoutParams.MATCH_PARENT);
row.setGravity(Gravity.CENTER_HORIZONTAL);
row.addView(theInflatedView);
ll.addView(row, i);
}
}
for(int i=0;i
您正在实例化EditText 2次,这就是您设置的值丢失的原因-
EditText setconditions = (EditText) theInflatedView.findViewById(R.id.setcondition); // 1st time
setconditions.setText(scheckx.condition);
setconditions = new EditText(getActivity()); // 2nd time
row.addView(setconditions);
删除
setconditions=neweditText(getActivity())代码>语句,您就可以开始了 您正在实例化EditText 2次,这就是您设置的值丢失的原因-
EditText setconditions = (EditText) theInflatedView.findViewById(R.id.setcondition); // 1st time
setconditions.setText(scheckx.condition);
setconditions = new EditText(getActivity()); // 2nd time
row.addView(setconditions);
删除setconditions=neweditText(getActivity())代码>语句,您就可以开始了 如果我这样做,应用程序就会崩溃。java.lang.IllegalStateException:指定的子级已具有父级。必须首先对子级的父级调用RemoveView()。如果I((ViewGroup)setconditions.getParent())。RemoveView(设置条件)使用EditText不显示。如果我这样做,应用程序将崩溃。java.lang.IllegalStateException:指定的子级已具有父级。必须首先对子级的父级调用RemoveView()。如果I((ViewGroup)setconditions.getParent())。RemoveView(设置条件)使用编辑文本不显示。特别感谢编辑sergey glotov特别感谢编辑sergey glotov