English 中文(简体)
• 如何在需要控制其邻国的安东纽斯山bu上 lo?
原标题:How to run a loop on a bunch of Android buttons that need to control their neighbors?
  • 时间:2010-11-09 08:37:02
  •  标签:
  • java
  • android

我有一份案文投入清单,每个清单都有编号。 左边是“......”指“+”的右边。

因此,它希望:

[ - ] [ 1111 ] [ + ]
[ - ] [ 1112 ] [ + ]
[ - ] [ 1113 ] [ + ]
etc...

我希望每个[-]机构改变其周围的实地价值,将其削减到1个,每个[+]机构增加其所剩外地的价值。

Is there a way that I can write a generic listener that would, upon instantiation, take as a param the id of the text field to be edited? setOnClickListener only takes a View.OnClickListener as a param, and that can t be given any extra params to hang onto either. Do I have to extend View.OnClickListener with my own custom listener to do this? Or is there some obvious way to accomplish this task that I m overlooking?

TIA.

最佳回答

* 请注意,这只是一个想法,现在由于不接近常设仲裁法院,我可以尝试。

因此,如何做到这一点:纽芬兰人延伸了观点类别,即他们有一种老化的方法,可以回去父母的观点。 因此,想像这样的听众:

public void onClick(View v){
TextView count = (TextView) ((v.getParent()).findViewById(R.id.counter));
switch(v.getId()){
case: R.id.incrementButton:
// increase value in count
break;
case R.id.decrementButton:
// decrease value in count
break;
}
}

不需要额外的班级或草率管理,所有班级都很简单。

问题回答

因此,它想延伸观点。 在ClickListener与我自己的习俗听众一道,是最直接的前进办法。 我生动地发表了一份案文,以及“+”和“纽扣”,并通过习惯听众提及案文领域。 这只是一种bit笑,但我看不到现在更直截了当的办法。

EDIT Leaving this solution up as it also works but like mrPjer s one better (even thought it s not, exactly, what I was hoping for).





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签