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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:53:43+00:00 2026-06-02T05:53:43+00:00

Ok so im making a media player app for android. everything was ok until

  • 0

Ok so im making a media player app for android. everything was ok until now. so far i have a list view that shows all .mp3 files on ur sdcard(internal and external) and when playing show a music visualizer. but i cant for the life of me alphabetize the list. everything is dynamic so xml doesnt work here.

 public class MusicPlayerActivity extends Activity {
  ListView musiclist;
  Cursor musiccursor;
  int music_column_index;
  int count;
  private Intent aIntent;
  public static String filename;
  private RelativeLayout mRelativeLayout;


  @Override
  public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        init_phone_music_grid();
        mRelativeLayout = new RelativeLayout(this);
        setContentView(mRelativeLayout);
        mRelativeLayout.addView(musiclist);

  }

  public void init_phone_music_grid() {
        System.gc();

        String[] projection = {
                MediaStore.Audio.Media._ID,
                MediaStore.Audio.Media.ARTIST,
                MediaStore.Audio.Media.TITLE,
                MediaStore.Audio.Media.DATA,
                MediaStore.Audio.Media.DISPLAY_NAME,
                MediaStore.Audio.Media.DURATION,
                MediaStore.Audio.Media.ALBUM
        };

        Uri allsongsuri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
        String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";

        musiccursor = managedQuery(allsongsuri, projection , selection, null, null);

        count = musiccursor.getCount();
        musiclist = (ListView) findViewById(R.id.PhoneMusicList);
        musiclist.setAdapter(new EfficientAdapter(getApplicationContext()));
        musiclist.setOnItemClickListener(musicgridlistener);

  }
  private OnItemClickListener musicgridlistener = new OnItemClickListener() {
        public void onItemClick(AdapterView parent, View v, int position,long id) {
              System.gc();
              music_column_index = musiccursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA);
              musiccursor.moveToPosition(position);
              filename = musiccursor.getString(music_column_index);
              aIntent = new Intent(v.getContext(), AudioFX.class);
              aIntent.getStringExtra(filename);
              startActivity(aIntent);
        }
      };

     class EfficientAdapter extends BaseAdapter {
      private Context mContext;

      public EfficientAdapter(Context c) {
          mContext = c;
      }
          public int getCount() {
                return count;
          }

          public Object getItem(int position) {
                return position;
          }

          public long getItemId(int position) {
                return position;
          }

          public View getView(int position, View convertView, ViewGroup parent) {
              System.gc();
              String id = null;
              TextView tv;
              if (convertView == null) {
              tv = new TextView(mContext.getApplicationContext());
              } else{
              tv = (TextView) convertView;
              }
              musiccursor.moveToPosition(position);
              music_column_index = musiccursor
              .getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE);
              id = musiccursor.getString(music_column_index);
              tv.setText(id);
              tv.setTextSize(20);
              return tv;
              }}}
  • 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-02T05:53:45+00:00Added an answer on June 2, 2026 at 5:53 am

    You just need to use DEFAULT_SORT_ORDER, like this:

    String sortOrder = MediaStore.Audio.Media.DEFAULT_SORT_ORDER;
    musiccursor = managedQuery(allsongsuri, projection , selection, null, sortOrder);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making the radio app.I have using the android media for playing radio
I'm making a media player application in android where one part of my screen
Hey, making a media player and need to know something. I have a menu
Making a social media app. I have a main viewFlipper with several views therein.
I am making a media player ,who can run in background. i have to
I am making media player and i have progress bar in it. When play
I am making an android app. I am making a service that runs in
I am making a Music player for my web app. After user upload some
I am making an android application that will play an mp3 file once a
I have a problem making Twitter display the main image in the Media sidebar,

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.