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. 使用线程执行堆栈StackTraceElement设计A
  2. android中-----JSON数据解析
  3. Android(安卓)TextView文字超出一屏不能
  4. android media server 解析1-media playe
  5. Android媒体相关开发应用程序接口
  6. MyEclipse9.0 安装Android(安卓)ADT14
  7. adb wifi 链接调试Android设备
  8. android 放大镜--ShapeDrawable妙用
  9. Android(安卓)ActionBar 使用详解
  10. ClipboardService(CBS)中的权限管理