Created
July 6, 2019 11:04
-
-
Save matthew-carroll/cec83e27aac493d313a525871d526395 to your computer and use it in GitHub Desktop.
Example of setting a View ID programatically in Android.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SomeActivity extends Activity { | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.some_layout); | |
MyView myView = new MyView(this); | |
myView.setId(R.id.desired_id); | |
addView(myView); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment