简体   繁体   中英

How Do I add a Click Event in a BindView?

How do i add click handler for a adapter with a bind view? Just starting out. Thank you.

Drop this into your binderView - I works for me anyways.

public void bindView(View v, Context context, final Cursor c) {

int tvGoto = c.getColumnIndexOrThrow("mColumn");
        final String gotoLink = c.getString(tvGoto);
        TextView gotoTxt = (TextView) v.findViewById(R.id.mRID);

        if (gotoTxt != null) {
            gotoTxt.setText(gotoLink);
        }
....

        v.setTag(gotoLink);

final ListView lv = getListView();
        lv.setEnabled(true);
        lv.setClickable(true);

        lv.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View v, int arg2,
                    long arg3) {

                String url = "";
                url = (String) v.getTag();

                Intent i = new Intent(QueryDisplay.this, DocView.class);
                QueryDisplay.this.startActivity(i);
            }
        });
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM