programmatically add id to R.id

后端 未结 3 595
庸人自扰
庸人自扰 2020-11-28 05:08

I am creating an EditText object which I then try to reference in a unit test. What is the best way to add a new id to R.id for this d

3条回答
  •  野性不改
    2020-11-28 05:36

    You can set ID's you'll use later in R.id class using an xml resource file, and let Android SDK give them unique values during compile time.

    res/values/ids.xml

    
    
    
        
        
        
    
    
    

    To use it in code:

    myEditTextView.setId(R.id.my_edit_text_1);
    

提交回复
热议问题