I created LinearLayout using the following code:
LayoutInflater inflater = getLayoutInflater();
LinearLayout container = (LinearLayout) inflater.inflate(R.layout.my_item, null);
My question is, is container.getId () equal to "R.layout.my_item" after executing the above code? Or do I need to set the id for the newly created layout using the code below?
container.setId(R.layout.my_item);
My sample code showed that I should explicitly set the id to a layout created from code that does not meet my expectations.
Thank.
Edit: The goal I want to set the id on the layout is the OnClick listener installed on the layout.
public void onClick(View v) {
Intent intent;
switch (v.getId()) {
case R.layout.my_item:
....
break;
source
share