如何将样式应用于android中动态创建的EditText?

如何将样式应用于android中动态创建的EditText?,android,android-styles,Android,Android Styles,我有一个按钮,每次点击该按钮,我都想动态创建新的编辑文本。 现在我的问题是,我在style.xml中为EditText提供了一种样式。现在,如何将该样式应用于动态创建的EditText 我的EditText代码是: List<EditText> allEdsLabReport ; String[] edsLabReport; EditText LabReportNm; AddMoreLabReport.setOnClickListener(new V

我有一个按钮,每次点击该按钮,我都想动态创建新的编辑文本。

现在我的问题是,我在style.xml中为EditText提供了一种样式。现在,如何将该样式应用于动态创建的EditText

我的EditText代码是:

    List<EditText> allEdsLabReport ;
    String[] edsLabReport;
    EditText LabReportNm;

    AddMoreLabReport.setOnClickListener(new View.OnClickListener() 
        {
           @Override
           public void onClick(View v) 
           {

           LabReportNm = new EditText(CaseReport.this);

          allEdsLabReport.add(LabReportNm);

          TableLayout tbl2 = (TableLayout)findViewById(R.id.TableLayoutLabReport);
          TableRow tr1 = new TableRow(CaseReport.this);

          tr1.addView(LabReportNm);
          tbl2.addView(tr1);

      }
        });
List allEdsLabReport;
字符串[]edsLabReport;
编辑文本LabReportNm;
AddMoreLabReport.setOnClickListener(新视图.OnClickListener()
{
@凌驾
公共void onClick(视图v)
{
LabReportNm=新编辑文本(CaseReport.this);
allEdsLabReport.add(LabReportNm);
TableLayout tbl2=(TableLayout)findViewById(R.id.TableLayoutLabReport);
TableRow tr1=新的TableRow(CaseReport.this);
tr1.addView(LabReportNm);
tbl2.addView(tr1);
}
});

这里提供了很多解决方案。请查看此信息,我认为目前不支持动态样式更改。您必须在创建视图(xml)之前设置样式。我知道动态样式更改当前不受支持。所以这个问题没有理由一直悬而未决。@cracker:karu j chu saheb!!顺便问一下,你是谁?@cracker哦,是的!非常感谢。如果您能为您的答案提供更多细节,那就太好了:)LabReportNm=neweditText(CaseReport.this);这是你的编辑text@NaveenTamrakar是的。LabReportNm是我动态创建的EditTextLabReportNm.setTextAppearance(getApplicationContext(),R.style.style.xml),我还更新了代码请检查请通过解释您所做的工作和原因来提高您的文章质量
new EditText(new ContextThemeWrapper(CaseReport.this, R.style.my_style));
LabReportNm.setTextAppearance(getApplicationContext(), R.style.style.xml)

editText.setTextAppearance(getApplicationContext(), R.drawable.demo.xml);