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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:40:41+00:00 2026-06-14T16:40:41+00:00

I have a database with team names and team numbers(both stored as strings –

  • 0

I have a database with team names and team numbers(both stored as strings – the numbers sometimes have letters in them)

I want it so when you click the “Open” button, it’ll bring up a popup that will have all of the teams’ names and numbers, and if you click one, it will close the popup and set both editText’s to the name & number.

                Dialog d = new Dialog(this);
            ScoutingFormData info = new ScoutingFormData(this);
            info.open();
            ScrollView scr = info.getData();
            info.close();
            d.addContentView(scr, null);
            d.show();

That’s from the main program, when you click “Open”, this happens. ScoutingFormData is my SQLite database, and here’s getData:

    public ScrollView getData() {
    String[] columns=new String[]{KEY_ROWID,KEY_NAME,KEY_NUM};
    Cursor c = ourDatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);
    ScrollView result=new ScrollView(null);
    int iID = c.getColumnIndex(KEY_ROWID);
    int iName = c.getColumnIndex(KEY_NAME);
    int iNum = c.getColumnIndex(KEY_NUM);
    LinearLayout vertlay = new LinearLayout(null);
    vertlay.setOrientation(LinearLayout.VERTICAL);
    for (c.moveToFirst(); !c.isAfterLast();c.moveToNext()){
        TextView tv=new TextView(null);
        tv.setText(c.getString(iNum)+"  "+c.getString(iName));
        vertlay.addView(tv);
    }
    result.addView(vertlay);
    return result;
}

So this builds the dialog, but how do I make it so the main program(the top code) will know when one of these TextViews have been clicked?

Side question: when making a View(like LinearLayout vertlay = new LinearLayout(null);), what context am I supposed to be using? I don’t fully understand what a ‘context’ is, so I’m really at a loss of what to replace “null” with.

  • 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-14T16:40:43+00:00Added an answer on June 14, 2026 at 4:40 pm

    How do I make it so the main program(the top code) will know when one of these TextViews have been clicked?

    Simply make tv clickable and add an OnClickListener.

    Side question: what context am I supposed to be using?

    You hinted that getData() is in your database adapter class ScoutingFormData, save a reference to the Context passed to the Constructor and reuse it later:

    private Context mContext;
    public ScoutingFormData(Context context) {
        mContext = context;
    }
    

    All together:

    TextView tv=new TextView(mContext);
    tv.setClickable(true);
    tv.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            // Do something
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our team we have a database project in visual Studio 2008 which is
I have just begun to use Visual Studio Team System 2008 Database Edition. I'm
i have database with two values id and val so i want to ask
I have database application, I want to allow the user to restore the deleted
I have a database table full of game by game results and want to
I have two database tables, Team ( ID, NAME, CITY, BOSS, TOTALPLAYER ) and
I have a button, Load Team, that, when clicked, I want to have a
I have a regex created from a list in a database to match names
I have two tables in the database Team:Id(int PK), Name(nvarchar) and Player:Id(int PK), Name(nvarchar),
I have two tables Team_DATA and Driver_PROFILE_DATA in an SQL database. For every driver_profile

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.