English 中文(简体)
Android——动态分配和检索
原标题:Android - assign and retrieve ID s dynamically

I know how to assing ID s dynamically by invoking setID(). For the ID s to be unique, I used to utilize ids.xml and pass to setID() ID s from the pre-generated pool of ID s.

问题1: 没有使用<编码>ids.xml就可转让ID s。 既然我无法预测,我需要多少国际发展数据。

我试图绕过问题1中提出的第一个问题,积极分配每一个问题,每个问题都以贴标签为根据(每个标签都是独有的),但没有办法确保国际发展法学会赢得的标记与在<代码>R.java上产生的国际发展法汽车进行串通。

问题1.1: 如何解决身份识别点命名碰撞的问题?

问题2: Assume I拥有我所分配和动态生成的身份证价值。 由于上述身份证没有出现在<代码>R.id 上,findViewById(赢 t 应用于检索该观点。 因此,在知道该身份证时如何检索该观点?

<><>Answer2: 只有在<>编码>onCreate(<>/code>>已恢复控制(定型)之后,才能通过相应的ID检索这一意见。

最佳回答

Is there any way to assign ID s without utilizing the ids.xml since I cannot anticipate how many ID s I will need in runtime?

保证每个观点都有独特的发展动态

for(int i =0 ; i < yourIDcount ; i++){
yourView.setId(i);
}

在知道该身份证时如何检索该观点?

View.findViewById(yourView.getId());

你们的意见可以用来id,因为每一种观点都具有独特性。 你可以回头看你想要的。

“动态”一词的产生时间是常年,因为你指定援助国为意见交换国,因为只有在一项活动成立时,才要求援助国,你可以确保所分配的补贴保持不变......

问题回答

从第17级改为第17级。

View.generateViewId()





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签