zoukankan      html  css  js  c++  java
  • 事件

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
      
     <TextView 
      android:id="@+id/tv71"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:text="@string/hello"/>
      <EditText
       android:id="@+id/et7"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
      />  
      <ImageView
       android:id="@+id/iv7"
       android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:src="@drawable/a"
      />  
    </LinearLayout>

    package com.szb;

    import java.io.IOException;

    import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnLongClickListener; import android.widget.ImageView; import android.widget.TextView;

    public class Day07  extends Activity{  private ImageView img;  private TextView tv;    @Override  protected void onCreate(Bundle savedInstanceState) {   // TODO Auto-generated method stub   super.onCreate(savedInstanceState);   setContentView(R.layout.day07);      img = (ImageView) findViewById(R.id.iv7);   tv = (TextView) findViewById(R.id.tv71);   img.setOnLongClickListener(new OnLongClickListener() {        //两个事件:long--> click    //            false --> 不去运行click    //            true  --> 去运行click    @Override    public boolean onLongClick(View v) {     try {      Day07.this.clearWallpaper();      Day07.this.setWallpaper(        Day07.this.getResources().        openRawResource(R.drawable.a));      tv.setText("设置成功");     } catch (IOException e) {      tv.setText("设置失败");      e.printStackTrace();     }     return true;    }   });  } }

    package com.szb;

    import android.app.Activity; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.view.View.OnKeyListener; import android.widget.EditText; import android.widget.ImageView;

    public class Day071  extends Activity{  private EditText et;  private ImageView iv;    @Override  protected void onCreate(Bundle savedInstanceState) {   super.onCreate(savedInstanceState);   setContentView(R.layout.day07);      et = (EditText) findViewById(R.id.et7);   iv = (ImageView) findViewById(R.id.iv7);   et.setOnKeyListener(new OnKeyListener() {    @Override    public boolean onKey(View v, int keyCode, KeyEvent event) {     if(event.getAction()==KeyEvent.ACTION_UP){      String str = et.getText().toString();      if(str.matches("\w+[@]\w+[.]\w+")){       iv.setImageResource(R.drawable.a);      }else{       iv.setImageResource(R.drawable.icon);      }     }     return false;    }   });  } }

    package com.szb;

    import android.app.Activity; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.widget.ImageView; import android.widget.TextView;

    public class Day72  extends Activity{    private TextView tv;  private ImageView iv;  @Override  protected void onCreate(Bundle savedInstanceState) {   super.onCreate(savedInstanceState);   setContentView(R.layout.day07);   tv = (TextView) findViewById(R.id.tv71);   iv = (ImageView) findViewById(R.id.iv7);   iv.setOnTouchListener(new OnTouchListener() {    @Override    public boolean onTouch(View v, MotionEvent event) {     tv.setText("("+event.getX()+","+event.getY()+")");     return false;    }   });  } }

  • 相关阅读:
    FreePbx
    ntpdate和date
    Linux系统/dev/mapper目录浅谈
    利用rsync做全平台备份
    windows 共享给 linux
    Linux、UNIX设置开机自动运行命令
    JNU周练1019
    JNU周练1013
    2013/7/30 JNU周练
    二叉树遍历
  • 原文地址:https://www.cnblogs.com/1396493331qq/p/6865727.html
Copyright © 2011-2022 走看看