Android:验证EditText

时间:2012-10-29 10:25:58

标签: android android-edittext ontouchlistener

我有2个 edittexts ans 2 imageviews ,我希望按钮点击的意图仅在两个edittexts都有效时才有效其中有一些值,并且两个图像视图都被触及了。
以下代码的问题在于,当我运行应用程序时,意图不在单击按钮上...

很抱歉代码格式不佳,但现在是:

iv_other.setOnTouchListener(new View.OnTouchListener() {

    public boolean onTouch(View arg0, MotionEvent event) {
            // TODO Auto-generated method stub
    switch (event.getAction()) {

    case MotionEvent.ACTION_DOWN:
      {
    anim1.start();
    mp.setLooping(true);
    mp.start();
    tv_your.setText("SCANNING....");
    count++;
       }
    break;
    case MotionEvent.ACTION_UP:
       {
    anim1.stop();
    mp.pause();
    iv_other.setImageResource(R.drawable.animation_0);
    tv_your.setText("Thumb Impression Captured");      
        }
    break;
        }
    return true;  
        }
    });
 iv_your.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View arg0, MotionEvent event) {
                // TODO Auto-generated method stub
        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
          {
        anim.start();
        mp.setLooping(true);
        mp.start();
        tv_other.setText("SCANNING....");
        count++;
           }
        break;
        case MotionEvent.ACTION_UP:
           {
        anim.stop();
        mp.pause();
        iv_your.setImageResource(R.drawable.animation_0);
        tv_other.setText("Thumb Impression Captured");      
            }
        break;
            }
        return true;  
            }
        });
   converttostring();
    l1=yourname.length(); 
    if(l1!=0)
    {
        count1++;
    }
    l2=othername.length();
    if(l2!=0)
    {
        count1++;
    }
        while(count1>1)
    {
    result.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            // TODO Auto-generated method stub
    if(count>1)
        {
                Intent next = new Intent("com.x9apps.compatibilityscanner.RESULT");
                startActivity(next);
        }   
    }
   });
    }
}
 private void converttostring() {
        // TODO Auto-generated method stub
      yourname =et_your.getText().toString();
      othername = et_other.getText().toString();
        }
    @Override
    public void onBackPressed() {
        // TODO Auto-generated method stub
        super.onBackPressed();
        finish();
    }

这些是我正在使用的变量。请快速帮助 int count = 0,l1,l2,count1 = 0; static String yourname,othername;

0 个答案:

没有答案