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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:57:11+00:00 2026-06-07T23:57:11+00:00

In my application I have a TextView, when the user clicks for thr first

  • 0

In my application I have a TextView, when the user clicks for thr first time on it I have to arrange the data in descending order,When user click on the same text view once again I have to arrange the data in ascending order.Is there any way to accomplish this?

My Code:

public void onClick(View v) {
    // TODO Auto-generated method stub
    boolean flag = false;
    db.open();
    Cursor c;
    if(flag==false)
    {
        c = db.getIncomeTitleDescitem(intent.getStringExtra("grpsdb"));
        startManagingCursor(c);
        flag=true;
    }                   
    else
    {
        System.out.println("inside else");
        c = db.getIncomeTitleAscitem(intent.getStringExtra("grpsdb"));
        startManagingCursor(c);
        flag=false;
    }
    ListView lv=(ListView)findViewById(R.id.listView1);     
    String[] fromdes = new String[] {db.KEY_DATE,db.KEY_DESC,db.KEY_INCOME,db.KEY_TOTAL};
    int[] todes = new int[] {R.id.text1 ,R.id.text3,R.id.text5,R.id.text7};
    SimpleCursorAdapter notes = new SimpleCursorAdapter(IncomeDetails.this, R.layout.columnview, c, fromdes, todes);                          
    lv.setAdapter(notes);  
    db.close();             
}
  • 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-07T23:57:12+00:00Added an answer on June 7, 2026 at 11:57 pm

    Yes you can easily track with a flag, based on click update the flag.. flag you can keep as boolean or int whatever you want. For your reference…

    boolean flag = false;   // false - first click, true - second click
    textView.setOnClickListener(new View.OnClickListener() {
    
        @Override
        public void onClick(View v) {
            if (flag == false) {
                flag = true;
                // do descending
             } else {
                 flag = false;
                 // do ascending
             }                
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TextView in my application. I want to align the text in
I have a textview in which i append text in two ways: First way:
in my application I have 3 edit boxes where the user enters in text.
In my application , I have to get date from the user. First I
Now I am doing an application.In my app I have to change textview value
In my music player application, I have got a TextView with Artist, Title and
In my application, I have a listview whose list item consists of a TextView
In my application,i have text view with long text. i need text wrapping like
In My application have time consuming process.There fore i try to do that operation
I am working with AlertDialog for user login to an application.I have displayed two

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.