1、点击按钮按下抬起事件

poslistview.xml

<?xml version="1.0" encoding="utf-8"?>
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

           android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:background="#578cc2" >

                    android:id="@+id/return1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="3dp"
            >
       


                    android:id="@+id/mapmodel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_margin="3dp"
            >
       

                    android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_toLeftOf="@+id/mapmodel"
            android:layout_toRightOf="@+id/return1"
            android:src="@drawable/tit_03_parent" />

   

 

          xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:cacheColorHint="@null"
        android:scrollbarAlwaysDrawVerticalTrack="true" />

postlistview.java

public class PosListView extends ListActivity implements OnClickListener,
  OnTouchListener {

....

private ImageView mapmode;

  mapmode = (ImageView) findViewById(R.id.mapmodel);
  mapmode.setOnClickListener(this);
  mapmode.setOnTouchListener(this);

 @Override
 public boolean onTouch(View v, MotionEvent event) {
  switch (v.getId()) {

  case R.id.mapmodel:
   if (event.getAction() == MotionEvent.ACTION_UP) {
    Log.d("test", "cansal button ---> cancel");
    mapmode.setBackgroundResource(R.drawable.ditu1);
   }
   if (event.getAction() == MotionEvent.ACTION_DOWN) {
    Log.d("test", "cansal button ---> down");
    mapmode.setBackgroundResource(R.drawable.ditu2);
   }
   break;
  }
  return false;
 }

 

2、点击listviewitem变色

在java中

  this.getListView().setSelector(R.drawable.bg);

在drawable目录下建bg.xml

<?xml version="1.0" encoding="UTF-8"?>

   
   

3、点击listviwitem中的某个按钮变色

在listview.xml中

                    android:id="@+id/zhidian1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             android:clickable="true"
            android:src="@drawable/call"
             />

在drawabel目录下建立call.xml

<?xml version="1.0" encoding="utf-8"?>

   
   

更多相关文章

  1. android的四种点击事件的设置
  2. android 之Dialog对话框(简易版)
  3. Android(安卓)点击按钮,文本文字改变
  4. android识别 单击和双击事件
  5. Android(安卓)service生命周期详解
  6. android camera2 api点击图片实现聚焦
  7. Android(安卓)监听Fragment界面的点击事件
  8. android camera2 api点击图片实现聚焦
  9. android 添加桌面窗口小部件(托至桌面需要点击按钮才能生成的)

随机推荐

  1. 苹果Mac系统如何安装pip命令?
  2. pg_probackup 性能测试
  3. 铭记历史,勿忘国耻,实用大刀术分享
  4. 一群帅小伙入伙运维后,人生轨迹发生了变化
  5. Cloudam云端云E算力平台在人工智能模型训
  6. IDEA激活码注册码密钥,2021年最新永久激活
  7. [灾备]归档和快照技术
  8. 案例 | Zabbix如何为中国铁路动车组WiFi
  9. [灾备]通过 NAS 与文件服务器结合构建数
  10. 03-K8s部署安装配置nginx-ingress和配置