[android] (new buttons in java not in xml) share onclick in one activity,

原创 2016年08月29日 13:57:57

public class SecondAct extends Activity implements View.OnClickListener {

first should implements View.OnClickListener  then you can override onclick

@Override
public void onClick(View v) {
    switch ((Integer) v.getTag()){
        case 3:{}
        case 4:{}

why getTag? cuz I dont know how to setId for these buttons defined in java:

Button btf = new Button(this);
btf.setText("to fullscreen");
btf.setTag(4);
btf.setOnClickListener(this);

but I can setTag in them; an int or else type; then in that switch , notice should transfer to (Integer) or something you set in setTag.


note: dont forget break in case end; otherwise it goes to last step straight.









            
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

We are unable to complete the review of your app since one or more of your In App Purchases have not

当我苦苦等待的项目在8天后,收到了一个苹果的的“ Rejected”!太纠结了......太苦逼了...... 首先说明,这个项目是有内置购买的。 苹果的反馈信息是: Missing IAP...

Android之JNI错误:no implementation found in native -java.lang.UnsatisfiedLinkError: Native method not

BUG: D/dalvikvm( 1704): Trying to load lib /data/data/com.ulang/lib/libulangaudio.so 0x41052a38 D/...
  • lqhed
  • lqhed
  • 2016-06-07 17:02
  • 572

class java/lang/AutoCloseable not found in *.platforms\android-19\android解决办法

上一篇博客说到了,如何更新android sdk的问题,首先说一下,我的android sdk是直接搜索百度关键词:android sdk下载搜到的下载资源,这个资源包已经集成了eclipse+adt...

sax错误:org.xml.sax.SAXParseException: Content is not allowed in prolog解决

原因及其解决办法: 1.xml编码错误 该xml是UTF-8编码的,如果该文件通过UltraEdit编辑后,会在无BOM头的UTF-8文件中加入BOM,但是DOM4j不认这个BOM(dom4j...
  • p_3er
  • p_3er
  • 2013-09-22 15:34
  • 6223

BEA-101165 Could not load user defined filter in web.xml: org.apache.struts2.dispatcher.FilterDispat

最近在写一个struts2 应用,修改struts.xml是,后台报错: BEA-101165 Could not load user defined filter in web.xml: org....

JAVA ONE 2013 in San Francisco 注定是javaFX爆起的一年

JAVA ONE  2013  in San Francisco  注定是javaFX爆起的一年。            一年一度的JAVA NOE 大会将在旧金山举行。javaFX已出世多年,但总...

Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in

1、错误描述 严重: Exception sending context initialized event to listener instance of class org.springframe...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)