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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:02:39+00:00 2026-05-26T00:02:39+00:00

I have two button b1 and b2 .If button b1 is pressed then perform

  • 0

I have two button b1 and b2 .If button b1 is pressed then perform a query q1 else if button b2 is pressed then perform an another query q2.

if(b1_click)
{
  mCursor=//query
}
else if(b2_click)
{
  mCursor=//query
}

Please tell me how can i implement this.How to implement b1_click method or any inbuilt method which tell that button is pressed.I tried

Cursor c;
c=//querys

    if(b1.isPressed())
    {
        next.setOnClickListener
        (
            new View.OnClickListener()
            {
                @Override public void onClick(View v) {
                    c=db.getData1(); (getData1 method return cursor)
                }
            }
        );
    } 
   tv.append(c.getString(column_number) (tv=TextView)

   "Same as above for b2"

It is saying that cursor (c) should be final
Help?

  • 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-26T00:02:40+00:00Added an answer on May 26, 2026 at 12:02 am

    First of all I would recommend going through some tutorials Hello Android and you could also follow the code and samples in Common Tasks and How to do them in Android.

    If you would read this carefully you would know that is very simple, something like this:

    public class MyActiviy extends Activity implements OnClickListener{
    
         protected void onCreate(Bundle savedInstance){
              super.onCreate(savedInstance);
              setContentView(R.layout.myLayout);
              findViewById(R.id.Button1).setOnClickListener(this);
              findViewById(R.id.Button2).setOnClickListener(this);
              //more code...
         }
    
         public void onClick(View v){
              switch(v.getId()){
                  case R.id.Button1:
                      //Button1 pressedd...do stuff
                      break;
                  case R.id.Button2:
                      //Button2 pressed...do some other stuff
                      break;
                  default:
                      break;
              }
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two .java's one called GUI.java, another called CustomPanel.java Once a button is
I have two elements (a button and an anchor tag) both with a dynamical
I have two validation groups: parent and child I have an add button that
I have two forms, one with a radio button that users must select to
I have two tables on a webform. On a button click I want to
I have two buttons with the same ID: <button type=submit onclick=//do something id=theID>button 1</button>
I have two fields which calculate a total, but I have a radio button
I have two panels in update panel. In panel1, there is button. If I
For simplicity lets say I have two flex mxml pages. form.mxml button.mxml If the
I have a vertical StackPanel with two elements: a Button and a ListBox. How

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.