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 8336365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:57:58+00:00 2026-06-09T03:57:58+00:00

I have a button, Load Team, that, when clicked, I want to have a

  • 0

I have a button, “Load Team”, that, when clicked, I want to have a pop-up list of teams in the database. My question is threefold:

  1. Currently I have an AlertDialog that pops up when clicking the
    button, but I cannot find how to populate the AlertDialog’s rows
    from the database. (currently static list)
  2. The second part of this question is that once I can populate the list, I want to display two returned columns concatenated together as follows: “Team Name (City)” or “team_ID – Team Name (City)”.
  3. Third, when they click the item, I want it to return the “team_id” column value
    from the query instead of the list position or list string value.

Is this possible? Here is my code to populate the list with static values:

final CharSequence[] team_list = {"Team 1", "Team 2", "Team 3"};

final AlertDialog.Builder load_builder = new AlertDialog.Builder(this);
load_builder.setTitle("@string/pick_team");
load_builder.setItems(team_list, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int item) {
        Toast.makeText(getApplicationContext(), team_list[item], Toast.LENGTH_SHORT).show();
        // I will sent team_id as parameter to query, to get all data for that team
    }
});

I’ve searched extensively but can’t seem to find the right answer. If this is better as a pop-up ListView and/or with its own layout.xml, please let me know.

  • 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-09T03:58:00+00:00Added an answer on June 9, 2026 at 3:58 am

    My problems have been resolved. I used a ListView inside of a Dialog. I used 2 ArrayLists, one storing strings for ListView, and the other storing corresponding ID (with matching array index).

    team_list.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
    
      <ListView
        android:id="@+id/listview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />
    </LinearLayout>
    

    ManageTeams.java:

    ArrayList<String> team_results = new ArrayList<String>();
    ArrayList<String> team_results_id = new ArrayList<String>();
    ListView team_listView;
    Dialog listDialog;
    ...
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.manage_teams);
    ...
        Button load_btn=(Button)findViewById(R.id.load_team_btn);
        load_btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                getTeams();
            }
        });
    ...
    }
    
    public void getTeam(String selected_team_id)
    {
        Team team;
    
        DatabaseHelper db = new DatabaseHelper(this);
        team = db.getTeam(selected_team_id);
        ...
    }
    
    public void getTeams()
    {
        final String colTeamID="team_id";
        final String colTeamName="team_name";
        final String colCity="city";
        final String colState="state";
    
        team_results.clear();
        team_results_id.clear();
    
        DatabaseHelper db = new DatabaseHelper(this);
        Cursor team_list = db.getTeams();
    
        if (team_list != null )
        {
            if (team_list.moveToFirst())
            {
                int counter = -1;
                do {
                    counter = counter + 1;
                    // assign strings to array for ListView
                } while (team_list.moveToNext());
            }
        }
    
        listDialog = new Dialog(this);
        listDialog.setTitle("Select Team");
        LayoutInflater li = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = li.inflate(R.layout.team_list, null, false);
        listDialog.setContentView(v);
        listDialog.setCancelable(true);
    
        team_listView = (ListView) listDialog.findViewById(R.id.listview);
        team_listView.setOnItemClickListener(this);
        team_listView.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, team_results));
        //now that the dialog is set up, it's time to show it
        listDialog.show();
    
        db.close();
    }
    ...
    public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3)
    {
        Log.i("ManageTeams", "onItemSelected");
        getTeam(team_results_id.get(pos));
        listDialog.dismiss();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have button that a user selects and I pop up a AlertDialog to
I have button, which fires an event, that deletes a record from the database.
I have a button which when pressed makes calls that load information from a
I have a Button that when clicked loads a Flex module in my AIR
i have a button, i want to show to user in page load normal
I have button in my application that opens android contact application for choose contact
I have a button that can have a focus css class associated with it
I have event Button that creates text box in run time. Private Sub Button1_Click(ByVal
What i'm trying to do is just simply have the button load an image
On a form I have a PictureBox , a button to load image in

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.