I am looking for creating an identifier in code without using an XML declaration. For example, I have code where I programmatically create a View like this
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_layout);
LinearLayout ll = (LinearLayout)findViewById(R.id.layout);
View v = new View(this);
v.setBackgroundColor(0xFFFF0000);
ll.addView(v, 100, 100);
}
and I can add v.setId(50), but I would like to add v.setId(R.id.some_id), and I would not want to add some_idto the xml file, I know this option.
My question is how to create R.id.some_idprogrammatically without installing it in an XML file. Thanks
source
share