How to pass set.tag() into onClick ?

Put your problem here if it does not fit any of the other categories.

How to pass set.tag() into onClick ?

Postby bianchi » Mon Feb 25, 2013 10:02 am

Guys,

I have a code :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. //display edit text for updating begin
  2.                 EditText Ed_id = new EditText(this);
  3.                 Ed_id.setInputType(InputType.TYPE_CLASS_TEXT);
  4.                 Ed_id.setTextColor(Color.GREEN);
  5.                 <span style="font-weight: bold">Ed_id.setText(String.valueOf(id));
  6.                 Ed_id.setTag(0);</span>
  7.                 Ed_id.setKeyListener(null);
  8.                 tr_update.addView(Ed_id);
  9.  
  10.  //listen to Bt_update click
  11.                                 Bt_update.setOnClickListener(new OnClickListener() {
  12.                                         @Override
  13.                                   public void onClick(View v) {
  14.                                                  <span style="font-weight: bold">Long id_update = (Long) v.getTag(0);</span>
  15.                                                                                
  16.                                                 <span style="font-weight: bold">db.updateMyList(id_update,</span> String.valueOf(v.getTag(1)), String.valueOf(v.getTag(2)));
  17.                                                 db.close();
  18.                                                 Toast toast = Toast.makeText(getApplicationContext(), " Item updated! ", Toast.LENGTH_SHORT);
  19.                                 toast.show();
  20.                                   }
  21.  
  22.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


My question is :
How to pass the value from 'Ed_id.setTag(0);' into 'db.updateMyList(id_update, String.valueOf(v.getTag(1)), '

Any helps or suggestions will be appreciated,
Thanks
bianchi
Freshman
Freshman
 
Posts: 2
Joined: Sat Feb 23, 2013 7:27 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 17 guests