Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8914595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:45:47+00:00 2026-06-15T04:45:47+00:00

sir, can you help me on how i can display the details from a

  • 0

sir, can you help me on how i can display the details from a sqlite by clicking its corresponding custom listview item? my listview contains three columns so i wanted it to be displayed in another activity where i can edit the information and delete, etc.. at first, i thought of using row id but gave up on the idea because if i tried to delete an item in database, i cannot use the deleted row id. so the row ids of listview and database won’t match. for ex. row ids from database 1,2,3… if i deleted row 2, if i add another item, it will just add to row 4… like this row 1,3,4. thanks for help in advance

public class CustomListView extends Activity {
final Context context = this;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    GroupDb info = new GroupDb(this);
    info.open();
    ArrayList<Contact> searchResults = info.getView();


    final ListView lv = (ListView) findViewById(R.id.srListView);
    lv.setAdapter(new MyCustomBaseAdapter(this, searchResults));
    info.close();

    lv.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            // TODO Auto-generated method stub
}

here is my custombaseadapter

public class MyCustomBaseAdapter extends BaseAdapter {
private static ArrayList<Contact> searchArrayList;

private LayoutInflater mInflater;

public MyCustomBaseAdapter(Context context, ArrayList<Contact> results) {
    searchArrayList = results;
    mInflater = LayoutInflater.from(context);
}

public int getCount() {
    return searchArrayList.size();
}

public Object getItem(int position) {
    return searchArrayList.get(position);
}

public long getItemId(int position) {
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.custom_row_view, null);
        holder = new ViewHolder();
        holder.txtName = (TextView) convertView.findViewById(R.id.name);

        holder.txtPhone = (TextView) convertView.findViewById(R.id.phone);

        holder.status = (TextView) convertView.findViewById(R.id.status);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.txtName.setText(searchArrayList.get(position).getName());

    holder.txtPhone.setText(searchArrayList.get(position).getPhoneNumber());

    holder.status.setText(searchArrayList.get(position).getStatus());

    return convertView;
}

static class ViewHolder {
    TextView txtName;
    TextView txtPhone;
    TextView status;
}
}

here is how i saved the database values with three fields/columns from GroupDb.class in my customlistview

public ArrayList<Contact> getView() 
{
    // TODO Auto-generated method stub
    ArrayList<Contact> results = new ArrayList<Contact>();
    String[] columns = new String[]{KEY_NAME, KEY_NUMBER, KEY_STATUS};
    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);
    String sName = "";
    String nName = "";
    String status = "";
    int iName = c.getColumnIndex(KEY_NAME);
    int iNumber = c.getColumnIndex(KEY_NUMBER);
    int iStatus = c.getColumnIndex(KEY_STATUS);
    Contact contact;
    for(c.moveToFirst(); ! c.isAfterLast(); c.moveToNext())
    {
        contact = new Contact();
        sName += c.getString(iName);
        nName += c.getString(iNumber);
        status += c.getString(iStatus);
        contact.setName(sName);
        contact.setPhoneNumber(nName);
        contact.setStatus(status);
        results.add(contact);
        sName = "";
        nName = "";
        status = "";
    }
    return results;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:45:48+00:00Added an answer on June 15, 2026 at 4:45 am

    You are maintaining arraylist of contacts. On click of list view get the position fetch contact object from that given position from your arraylist. You must have to save primary key column in your COntact Class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sir, how can i refresh my custom listview using baseadapter. i don't know what
Sir/Madam, I am going to develop a insert command by clicking Add to display
Sir, I am doing the task on fetching the contents from the xml file.I
Hello sir i send the arraylist through url pass from android to php all
Edited........ sorry Sir I was referring this piece of code from Stephen Toub's article..
sir, how can i return the rowid of my database depending on the inputs
Need help with this error. Can't see what's wrong. Error: Warning: mysql_query() expects parameter
sir, how do i refresh my listview if i pressed the back button in
sir, please help me in my program. i plan to ring an alarm if
Dear Sir/m'am How can i replace ther deprecated ereg_replace with preg_replace or str_replace and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.