I am looking for creating ID in code without using XML declaration. For example, I have code, where I programmatically create 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 add v.setId(R.id.some_id)
and I wouldn't like add some_id
into xml file, this option I know.
My question is, how to create R.id.some_id
programmatically without setting it in XML file. Thanks