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 点击按钮,文本文字改变
  3. android识别 单击和双击事件
  4. Android 监听Fragment界面的点击事件
  5. Android 下listview不能相应onItemClick事件
  6. android 添加桌面窗口小部件(托至桌面需要点击按钮才能生成的)
  7. Android 扫描SDCard上的音乐文件以及监听扫描事件
  8. Android事件传递机制【Touch事件】

随机推荐

  1. 读懂Android(安卓)(1):使用Android内部的
  2. Android(安卓)onTouchEvent, onClick及on
  3. Cordova插件调用Android原生Activity
  4. android的URI学习
  5. 移动开发参考书之Android篇
  6. Android(安卓)onTouchEvent, onClick及on
  7. 【原创】Android锁定横竖屏、splash,全屏
  8. Android(安卓)4.0 Launcher2源码分析——
  9. 开源 Android(安卓)开发平台 Rexsee 开发
  10. Android(安卓)7.1 车机 Android(安卓)系