listview item点击事件失效,是什么问题?求大神指导,卡了很久了,谢谢。

package com.example.dance_society_masystem;

import java.util.ArrayList;
import java.util.Map;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class InComeBookActivity extends Activity {

ImageView InComeBookReturn;
ListView ListViewInComeBook;
CursorAdapter adapter;
private MyOpenHelper helper;
private Cursor cur;

String ICMoney;
String ICTime;
String ICRemarks;
String ICSource;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_incomebook);

    ListViewInComeBook = (ListView) findViewById(R.id.ListViewInComeBook);
    InComeBookReturn = (ImageView) findViewById(R.id.InComeBookReturn);

    helper = new MyOpenHelper(this);

    InComeBookReturn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
        //  finish();

            Intent intent = new Intent();

            intent.setClass(InComeBookActivity.this, MainActivity.class);
            startActivity(intent);


        }
    });

    SQLiteDatabase db = helper.getReadableDatabase();

    // select 列名 ,列名 ..from表名where ..
    cur = db.query("InCome", // 表名
            null, // 选择的列的列名 String[]
            null, // where后面的语句
            null,// 行条件的参数 String[]
            null,// group by 后面的语句
            null, // having 后面的语句
            null // 排序
    );


    adapter = new CursorAdapter(this, cur) {

        @Override
        public View newView(Context context, Cursor cursor, ViewGroup parent) {
            View view = LayoutInflater.from(InComeBookActivity.this)
                    .inflate(R.layout.activity_incomebook_listitem, null);
            return view;
        }

        // 绑定activity_incomebook_listitem视图
        @Override
        public void bindView(View v, Context context, Cursor cursor) {

            final TextView tvICMoney = (TextView) v
                    .findViewById(R.id.tvICBookMoney);
            final TextView tvICTime = (TextView) v
                    .findViewById(R.id.tvICBookTime);
            final TextView tvICRemarks = (TextView) v
                    .findViewById(R.id.tvICBookRemarks);
            final TextView tvICSource = (TextView) v
                    .findViewById(R.id.tvICBookSource);
            final ImageView goIn = (ImageView) v
                    .findViewById(R.id.goIn);




            int columnIndex = cursor.getColumnIndex("Money");
            ICMoney = cursor.getString(columnIndex);

            int columnIndex2 = cursor.getColumnIndex("InComeTime");
            ICTime = cursor.getString(columnIndex2);

            int columnIndex3 = cursor.getColumnIndex("Remarks");
            ICRemarks = cursor.getString(columnIndex3);

            int columnIndex4 = cursor.getColumnIndex("Source");
            ICSource = cursor.getString(columnIndex4);





            // 设置显示
            tvICMoney.setText(ICMoney);         
            tvICTime.setText(ICTime);
            tvICRemarks.setText(ICRemarks);
            tvICSource.setText(ICSource);



        }

    };
    ListViewInComeBook.setAdapter(adapter);

    Log.i("zxj", "ListView000");
    // 传值到UpdateInComeBookActivity
**  ListViewInComeBook.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?>  parent, View view, int position, long id) {

            Map<String, Object> click = (Map<String, Object>) parent.getItemAtPosition(position);

            Log.i("zxj", "ListView");

            String income_id = click.get("_id").toString();
            String income_money = click.get("Money").toString();
            String income_time = click.get("InComeTime").toString();
            String income_remarks = click.get("Remarks").toString();
            String income_source = click.get("Source").toString();


            Bundle bundle = new Bundle();
            bundle.putString("icid", income_id);
            bundle.putString("icmoney", income_money);
            bundle.putString("ictime", income_time);
            bundle.putString("icremarks", income_remarks);
            bundle.putString("icsource", income_source);

            Intent intent = new Intent();

            intent.putExtras(bundle);

            intent.setClass(InComeBookActivity.this, UpdateInComeBookActivity.class);
            startActivity(intent);


        }

    });
}**

}

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!