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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:23:16+00:00 2026-05-24T19:23:16+00:00

My question has three parts. My Layout consists of 26 Buttons: ButtonA, ButtonB, ButtonC…ButtonZ

  • 0

My question has three parts.

My Layout consists of 26 Buttons: ButtonA, ButtonB, ButtonC…ButtonZ

The buttons are arranged in order on the screen. When the button is clicked I want to capture the click event and filter a SQLiteDB of words by the first letter that was clicked.

How do I write the minimum amount of code that will capture the click, identify the button’s corresponding letter, and return the letters that begin with the selected letter from the SQLite Database?

Below is my code that has not been optimized for code brevity.

//Create your buttons and set their onClickListener to "this"
    Button b1 = (Button) findViewById(R.id.Button04);   
    b1.setOnClickListener(this);

    Button b2 = (Button) findViewById(R.id.Button03);   
    b2.setOnClickListener(this);


     //implement the onClick method here
public void onClick(View v) {
   // Perform action on click
  switch(v.getId()) {
    case R.id.Button04:
        //Toast.makeText(this,"test a",Toast.LENGTH_LONG).show();

     // Do the SqlSelect and Listview statement for words that begin with "A" or "a" here.

       break;
    case R.id.Button03:
        //Toast.makeText(this,"test b",Toast.LENGTH_LONG).show();

 // Do the SqlSelect and Listview statement for words that begin with "A" or "a" here.
      break;
  }

}

  • 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-24T19:23:17+00:00Added an answer on May 24, 2026 at 7:23 pm

    If you have lots of characters and a button for each character, I would probably extend the “BaseAdapter” class and make a ButtonAdapter holding the alphabet as a character array, instead of actually making 28:ish buttons… …if I understood the problem correctly?

    The getView could look something like this:

      public View getView(int position, View convertView, ViewGroup parent) {
        Button button;
    
        if (convertView == null) {
            button = new Button(mContext);
            button.setTag(alphabet[position]);
            button.setOnClickListener(clickListener);
        } else {
            button = (Button) convertView;
        }
    
        button.setText(alphabet[position]);
        return button;
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question really has three related parts which I hope you can help me
My questions are divided into three parts Question 1 Consider the below code, #include
I know this question has kind-a started religious wars in past and there might
I'am aware there has been a generic question about a best IDE in C++
I see there is a question here but there is no definite answer. Has
This question has been asked before ( link ) but I have slightly different
This question has been discussed in two blog posts ( http://dow.ngra.de/2008/10/27/when-systemcurrenttimemillis-is-too-slow/ , http://dow.ngra.de/2008/10/28/what-do-we-really-know-about-non-blocking-concurrency-in-java/ ),
The question has been asked: No PHP for large projects? Why not? It's a
This question has spawned out of this one. Working with lists of structs in
This isn't a question that has a black/white yes/no answer, this is more a

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.