【问题标题】:toggle button for android [closed]android的切换按钮[关闭]
【发布时间】:2012-12-11 21:53:28
【问题描述】:

我正在尝试为 android 应用程序创建一个切换按钮。切换按钮将在按下时交换图像,然后在再次按下时交换回原始图像。我正在使用与 phonegap 集成的 Eclipse 作为我的 IDE。谁能帮我这个?我在网上找到了一些android的java源代码,但它们似乎不可用。

【问题讨论】:

    标签: android eclipse cordova togglebutton


    【解决方案1】:
    //get ToggleButton reference
     ToggleButton tg;
     tg = (ToggleButton) findViewById(R.id.toggleButton1);
    //set listener       
     tg.setOnClickListener(this);
    //track the status of toggle button
     @Override
        public void onClick(View v) {
        // TODO Auto-generated method stub
        if((tg.isChecked()))
        {
            System.out.println("checked");
           //do wt ever you wanted to do on checked 
        }
        else
        {
                System.out.println("Unchecked");
    
        }
       }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-31
      • 1970-01-01
      • 1970-01-01
      • 2013-06-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多