What are “tag” and “id” on Layouts?

后端 未结 3 564
执念已碎
执念已碎 2021-02-05 07:48

I know how the switch statement works but I don\'t know what this means (R.id.webbutton). Can anyone please explain what it is and also what is TAG? Is there any guide for the

3条回答
  •  情书的邮戳
    2021-02-05 08:05

    Id is id of your xml's components [may be views like textview,edittext... or viewgroup like linearlayout ,relativelayout... or anything else] in xml simply you can get reference to them in java code by saying

    (R.id."id of your view in xml")

    but firstly you should use setContentView(R.layout."name of xml file in layout/res in your project") this xml file which you want to use it's components .

    TAG i use it when i want to show message in logcat [tool in eclipse you can watch your app messages when it is running] by saying String TAG= yourclassname.class.getsimpleName();

    and use it in Log.d(TAG,"any string here"+some variable in my class i want to know it's value in a particular time when app running );

    i hope that i made it clear to you .

提交回复
热议问题