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

  • Home
  • SEARCH
  • 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 3304970
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:07:05+00:00 2026-05-17T21:07:05+00:00

I am using this following code which creates a ListView with text and an

  • 0

I am using this following code which creates a ListView with text and an icon but the problem that I have which the following I want the array to be dynamic instead of static so my list gets created dynamically not statistically. My ultimate goal is to retrieve specific strings from my Db and to display it then on the Listview where every string would be in each row.
Thank you very much in advance.

My source code:

    import java.util.ArrayList;
    import android.app.Activity;
    import android.app.ListActivity;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.AdapterView;
    import android.widget.AdapterView.OnItemClickListener;
    import android.widget.ArrayAdapter;
    import android.widget.ImageView;
    import android.widget.ListView;
    import android.widget.TextView;
    import android.widget.Toast;

    public class History extends ListActivity implements OnItemClickListener {

String keyWord = "";
String histDesRes = "";
String history = "";
String rawImage;
ArrayList<String> Ra = new ArrayList<String>();
SQLiteDatabase mydb;
TextView selection;
public String[] result={keyWord, "ipsum", "dolor",
        "sit", "amet",
        "consectetuer", "adipiscing", "elit", "morbi", "vel",
        "ligula", "vitae", "arcu", "aliquet", "mollis",
        "etiam", "vel", "erat", "placerat", "ante",
        "porttitor", "sodales", "pellentesque", "augue", "purus"};

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.history);
    populate();




}


@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    //populate();
}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    //populate();
}

@Override
protected void onStart() {
    // TODO Auto-generated method stub
    super.onStart();
    //populate();
}

void populate() {

    mydb = openOrCreateDatabase("vivo_id.db",
            SQLiteDatabase.CREATE_IF_NECESSARY, null);
    Cursor c = mydb.query("VIVOID", null, null, null, null, null, null);
    // start the managing cursor
    startManagingCursor(c);
    // move to first row
    c.moveToFirst();
    // continue searching until it is the last row in the column
    while (c.isAfterLast() == false) {

        rawImage = c.getString(c.getColumnIndex("couponThumbnailResult"));
        keyWord = c.getString(c.getColumnIndex("keyWordResult"));
        histDesRes = c.getString(c.getColumnIndex("historyDescriptionResult"));
        //Toast.makeText(getApplicationContext(),
                //history, Toast.LENGTH_LONG).show();
        history = keyWord+" "+ histDesRes;
        c.moveToNext();
        }

    // close everything
    c.close();
    mydb.close();
    setListAdapter(new IconicAdapter());
    selection=(TextView)findViewById(R.id.selection);

}

public void onListItemClick(ListView parent, View v, int position, long id) {
    Toast.makeText(getApplicationContext(),
            "Inside listen", Toast.LENGTH_LONG).show();

}

class IconicAdapter extends ArrayAdapter {
    IconicAdapter() {
        super(History.this, R.layout.row, result);
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = getLayoutInflater();
        View row = inflater.inflate(R.layout.row, parent, false);
        TextView label = (TextView) row.findViewById(R.id.label);
        label.setText(result[position]);

        ImageView icon = (ImageView) row.findViewById(R.id.icon);


            icon.setImageResource(R.drawable.ok);

        return (row);
    }
}

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

}

    }

    /**
     * On Item click event for the list view
     */
  • 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-05-17T21:07:06+00:00Added an answer on May 17, 2026 at 9:07 pm
        while (c.isAfterLast() == false) {
           rawImage = c.getString(c.getColumnIndex("couponThumbnailResult"));
           keyWord = c.getString(c.getColumnIndex("keyWordResult"));
           histDesRes = c.getString(c.getColumnIndex("historyDescriptionResult"));
           //Toast.makeText(getApplicationContext(),
           //history, Toast.LENGTH_LONG).show();
           history = keyWord+" "+ histDesRes;
           //Use an ArrayList to store your results from the DB
           c.moveToNext();
        }
    
     String[] results = yourArrayList.toArray();
    

    use this array in your adapter….

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

Sidebar

Related Questions

I have the following code which I'm using to get the user to input
I'm using Thinking Sphinx for full-text search, following this video . I'd like to
I have the following line: 14:48 say;0ed673079715c343281355c2a1fde843;2;laka;hello ;) I parse this by using a
I have a PlaceHolder control inside of a ListView that I am using to
I have the following situation in code, which I suspect may be a bit
I have the following C# code (not mine) which pulls an image out of
I get this message: Cannot find the X.509 certificate using the following search criteria:
Following the advice of wcoenen, I've decided to try using registration-free COM. This works
Since I have started using this site, I keep hearing about the Boost library.
anyone have any experience using this? if so, is it worth while?

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.