我正在开发一个应用程序,其中我通过编程方式创建一个EditText:
EditText edText = new EditText(this);
edText.setId(1);
edText .setLayoutParams(new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,0f));
edText .setInputType(InputType.TYPE_CLASS_NUMBER);
edText.setHint("dsgsdgsgs");
tableLayout.addView(edText);
这里我通过代码edText.setId(1);
将EditText的id设置为整数"1"。
但是我需要的是 - 我想要将ID以字符形式设置,例如:
edText.setId("edittext_hello");
我希望能够通过该ID访问它。请问我该如何实现这个任务,请帮忙。
LinearLayout linearLayout= (LinearLayout) findViewById(R.id.sale_aditionals_layout);
然后MaterialEditText materialEditText = (MaterialEditText) linearLayout.findViewWithTag(entry.getKey());
- FLBKernel