I want to dynamically create a button but am having an issue when it comes to setting an ID for it. I tried putting an integer value in there but keep getting an error that says "Expected Resource of Type ID."
The issue is that I DONT want to create this Button in my XML file and yet I need a way to track it with an ID. Please Help.
Button changeButton = new Button(getApplicationContext());
changeButton.setText("Change");
changeButton.setId(1);//Keep Getting an error here
HashMap
). You can also define an ID resource (e.g.,res/values/ids.xml
, with<item type="id" name="button_id">1</item>
elements) and use that ID (R.id.button_id
, in this case).