gpt4 book ai didi

java - 数组中 TextEdit 中的参数不正确

转载 作者:太空宇宙 更新时间:2023-11-04 12:42:50 25 4
gpt4 key购买 nike

抱歉我的英语不好。我用谷歌翻译。我只是为安卓编写了一个游戏。对于我的问题,我在数组中进行游戏内检查。在这种情况下,它是显示的支票的值(value)。然后支票的金额会显示在文本编辑中并支付按钮。当按下按钮时,将在文本编辑期间支付输入的值。但是,只有支付的全部费用,没有部分金额。我的问题是没有交给编辑后的文本。只是从头开始显示传递的值。为什么?我的错误在哪里?我用一些??标记了字符区域。

 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);
}
}

最佳答案

您实例化了 EditText 两次,这就是您设置的值丢失的原因 -

                    EditText setconditions = (EditText) theInflatedView.findViewById(R.id.setcondition); // 1st time
setconditions.setText(scheckx.condition);
setconditions = new EditText(getActivity()); // 2nd time
row.addView(setconditions);

删除 setconditions = new EditText(getActivity()); 语句,就可以开始了!!

关于java - 数组中 TextEdit 中的参数不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36658021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com