1. Are you ready for the Galaxy S20? Here is everything we know so far!

what are the steps in make a onListItemClick

Discussion in 'Android Development' started by flyhigh427, Jul 8, 2013.

  1. flyhigh427

    flyhigh427 Member
    Thread Starter

    hey yall
    what is the int position for?

    i have this in my listactivity and the below code in my edit class.
    i cant seem to figure out what im soposed to put in place of employee_id.
    thanks all

    Code (Text):
    1.  
    2.  
    3. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B]
    4. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onListItemClick(ListView parent, View view, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] position, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]long[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] id) {[/SIZE][/LEFT]
    5.  
    6. [LEFT][SIZE=2]Intent intent = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Intent([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], addstuff.[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
    7.  
    8. [SIZE=2]Cursor cursor = (Cursor) [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]adapter[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].getItem(position);[/SIZE]
    9. [LEFT][SIZE=2]intent.putExtra([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"EMPLOYEE_ID"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], cursor.getInt(cursor.getColumnIndex([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"_id"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])));[/SIZE]
    10. [SIZE=2]startActivity(intent);[/SIZE][/LEFT]
    11. [/LEFT]
    12.  
    13.  
    14.  
    15. [LEFT][SIZE=2]}[/SIZE][/LEFT]
    16.  
    17.  
    18. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][/LEFT]
    19.  
    20.  
    21. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] addstuff [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]extends[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Activity{[/SIZE][/LEFT]
    22.  
    23. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]protected[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] EditText [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]have1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE][/LEFT]
    24.  
    25.  
    26.  
    27. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]protected[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]supplyId[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
    28.  
    29. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] String [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DATABASE_TABLE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2] = [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"mysupplystable"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
    30. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] String [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]KEY_ITEMS[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2] = [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"items"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]; [/SIZE]
    31. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]final[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] String [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]KEY_ROWID[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2] = [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"_id"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE][/LEFT]
    32. [/LEFT]
    33.  
    34.  
    35.  
    36.  
    37.  
    38. [LEFT][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/COLOR][/SIZE][/COLOR][/SIZE]
    39.  
    40. [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onCreate(Bundle savedInstanceState) {[/SIZE]
    41. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2].onCreate(savedInstanceState);[/SIZE]
    42. [SIZE=2]setContentView(R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]mysupply_edit[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE][/LEFT]
    43. [/LEFT]
    44.  
    45.  
    46.  
    47.  
    48.  
    49. [LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]supplyId[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = getIntent().getIntExtra([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"_ID"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], 0);[/SIZE]
    50.  
    51. [SIZE=2]SQLiteDatabase db = ([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] DatabaseHelper([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2])).getWritableDatabase();[/SIZE][/LEFT]
    52.  
    53.  
    54.  
    55.  
    56.  
    57.  
    58. [LEFT][SIZE=2]Cursor cursor =db.query([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DATABASE_TABLE[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] String[] {[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]KEY_ROWID[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2],[/SIZE]
    59.  
    60. [I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]KEY_ITEMS[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]}, [/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]KEY_ROWID[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2] + [/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"="[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] + [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]supplyId[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2],[/SIZE]
    61. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE][/LEFT]
    62. [/LEFT]
    63.  
    64.  
    65.  
    66.  
    67.  
    68.  
    69. [LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] (cursor.getCount() == 1)[/SIZE]
    70.  
    71. [SIZE=2]{[/SIZE]
    72. [LEFT][SIZE=2]cursor.moveToFirst();[/SIZE][/LEFT]
    73. [/LEFT]
    74.  
    75.  
    76.  
    77.  
    78.  
    79. [LEFT][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]have1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = (EditText) findViewById(R.id.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]have1[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]);[/SIZE]
    80.  
    81. [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]have1[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].setText(cursor.getString(cursor.getColumnIndex([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"items"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])));[/SIZE][/LEFT]
    82.  
    83.  
    84.  
    85.  
    86.  
    87.  
    88.  
    89. [LEFT][SIZE=2]}[/SIZE][/LEFT]
    90.  
    91.  
    92.  
    93. [LEFT][SIZE=2]}[/SIZE][/LEFT]
    94.  
    95.  
    96.  
    97. [LEFT][SIZE=2]}[/SIZE][/LEFT]
    98.  
    99.  
     



    1. Download the Forums for Android™ app!


      Download

       
  2. flyhigh427

    flyhigh427 Member
    Thread Starter

    i guess position means screen position and id is for coloums right?
    so how do you know witch row id your on in a listview ,if its scrolling ?
     
  3. out of ideas

    out of ideas Android Enthusiast

    you have your listitem click after oncreate right? nothow it looks in that post.

    the row id stays the same if you scroll or not.
     
    flyhigh427 likes this.
  4. flyhigh427

    flyhigh427 Member
    Thread Starter

    hey out of ideas what does the emp and mgr stand for when using rawqueary?
    many thanks
     
  5. flyhigh427

    flyhigh427 Member
    Thread Starter

    hey when i wrap code in code tags i have to type in code why?
     
  6. out of ideas

    out of ideas Android Enthusiast

    I dont know never used rsawquery.

    cuz code belong in code ;)
     
  7. flyhigh427

    flyhigh427 Member
    Thread Starter

    i got it i think now im stuck again
     
Loading...

Share This Page

Loading...