简体   繁体   中英

How to retrieve particular data on clicking record from arraylist (Sqlite database)in Android??

i have show records in array-list on one layout.now i want to show like....if i click on particular record then that particular record must show on layout..ie on next or another layout fully.i used Sqlite database.

lvUsers.setClickable(true);


    lvUsers.setOnItemClickListener(new AdapterView.OnItemClickListener() 
    {

          public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) 
          {

            Object o = lvUsers.getItemAtPosition(position);
            UserBO obj = (UserBO) o;
            Toast.makeText(Select.this, "Record Selected= "+obj.getId()+" "+obj.getName()+" "+obj.getAge()+" "+obj.getDate()+" "+obj.getTime(), Toast.LENGTH_LONG).show();              

            Intent i = new Intent(Select.this,ShowProfile.class);
                startActivity(i);   

         }


        });

Thanks in Advance----

setOnItemClickListener to the ListView as follows

lvUsers.setOnItemClickListener(this);

implement the interface

OnItemClickListener

and then add the following override method

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

}

In the above method the parameter position indicates the the position of the item has been clicked in ListView

By using this you can get the clicked item and pass it to the next Activity.

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