什么是“标签"?和"id"在布局上? [英] What are "tag" and "id" on Layouts?

查看:139
本文介绍了什么是“标签"?和"id"在布局上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道switch语句如何工作,但是我不知道这意味着什么(R.id.webbutton).谁能解释一下这是什么以及TAG是什么? 有针对初学者的指南吗?我的意思是绝对的初学者.

解决方案

Id是xml中xml组件的ID [可以是textview,edittext ...之类的视图,也可以是linearlayout,relativelayout ...等之类的viewgroup]只需说

即可在Java代码中获得对它们的引用

(R.id.您在xml中的视图ID")

但是首先您应该使用setContentView(R.layout.项目中布局/res中xml文件的名称") 您要使用其组件的xml文件.

TAG,当我想在logcat中显示消息时使用它[Eclipse的工具,它可以在运行时观看您的应用消息],方法是说String TAG = yourclassname.class.getsimpleName();

并在Log.d(TAG,这里的任何字符串" +我班上的一些变量,我想知道它在应用运行的特定时间内的值)中使用它;

我希望我对你说清楚.

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 beginners? I mean absolute beginners.

解决方案

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 .

这篇关于什么是“标签"?和"id"在布局上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆