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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:48:55+00:00 2026-06-10T00:48:55+00:00

I am building song list application. I want to display splash screen while loading

  • 0

I am building song list application. I want to display splash screen while loading data. For that use I set an AsyncTask combined with ViewSwitcher to switch xml layout beetween splash screen (just logo and circle progressbar) and main screen. The problem is when it comes to puting data in ListView, I am using BaseAdapter which is in separate class, and it throws error "The Constructor LazyAdapter(Home.LoadViewTask, ArrayList<HashMap<String,String>>) is undefined".

This is source of Home Class which has AsyncTask:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main);

    mBtnNaslovnica = (Button) findViewById(R.id.mBtnNaslovnica);
    mBtnNaslovnica.setSelected(true);

    new LoadViewTask().execute();
}

//To use the AsyncTask, it must be subclassed
public class LoadViewTask extends AsyncTask<Void, Integer, Void>
{
    //A TextView object and a ProgressBar object
    private TextView tv_progress;
    private ProgressBar pb_progressBar;

    //Before running code in the separate thread
    @Override
    protected void onPreExecute() 
    {
        //Initialize the ViewSwitcher object
        viewSwitcher = new ViewSwitcher(Home.this);
        /* Initialize the loading screen with data from the 'loadingscreen.xml' layout xml file. 
         * Add the initialized View to the viewSwitcher.*/
        viewSwitcher.addView(ViewSwitcher.inflate(Home.this, R.layout.init, null));

        //Set ViewSwitcher instance as the current View.
        setContentView(viewSwitcher);
    }

    //The code to be executed in a background thread.
    @Override
    protected Void doInBackground(Void... params) 
    {
        ArrayList<HashMap<String, String>> songsList = new ArrayList<HashMap<String, String>>();
        XMLParser parser = new XMLParser();
        String xml = parser.getXmlFromUrl(URL); // getting XML from URL
        Document doc = parser.getDomElement(xml); // getting DOM element

        NodeList nl = doc.getElementsByTagName(KEY_SONG);
        // looping through all song nodes <song>
        for (int i = 0; i < nl.getLength(); i++) {
            // creating new HashMap
            HashMap<String, String> map = new HashMap<String, String>();
            Element e = (Element) nl.item(i);
            // adding each child node to HashMap key => value
            map.put(KEY_ID, parser.getValue(e, KEY_ID));
            map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));
            map.put(KEY_ARTIST, parser.getValue(e, KEY_ARTIST));
            map.put(KEY_DURATION, parser.getValue(e, KEY_DURATION));
            map.put(KEY_THUMB_URL, parser.getValue(e, KEY_THUMB_URL));

            // adding HashList to ArrayList
            songsList.add(map);
        }

        list=(ListView)findViewById(R.id.list);

        // Getting adapter by passing xml data ArrayList
        adapter=new LazyAdapter(this, songsList);        
        list.setAdapter(adapter);
        // Click event for single list row
        list.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {    

            }
        });

        return null;
    }

    //After executing the code in the thread
    @Override
    protected void onPostExecute(Void result) 
    {
        /* Initialize the application's main interface from the 'main.xml' layout xml file. 
         * Add the initialized View to the viewSwitcher.*/
        viewSwitcher.addView(ViewSwitcher.inflate(Home.this, R.layout.main, null));
        //Switch the Views
        viewSwitcher.showNext();
    }
}

//Override the default back key behavior
@Override
public void onBackPressed() 
{
    //Emulate the progressDialog.setCancelable(false) behavior
    //If the first view is being shown
    if(viewSwitcher.getDisplayedChild() == 0)
    {
        //Do nothing
        return;
    }
    else
    {
        //Finishes the current Activity
        super.onBackPressed();
    }
}

And this is the source of LazyAdapter class:

private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
public ImageLoader imageLoader; 

public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
    activity = a;
    data=d;
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader=new ImageLoader(activity.getApplicationContext());
}

public int getCount() {
    return data.size();
}

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

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

public View getView(int position, View convertView, ViewGroup parent) {
    View vi=convertView;
    if(convertView==null)
        vi = inflater.inflate(R.layout.list_row, null);

    TextView title = (TextView)vi.findViewById(R.id.title); // title
    TextView artist = (TextView)vi.findViewById(R.id.artist); // artist name
    TextView duration = (TextView)vi.findViewById(R.id.duration); // duration
    ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image

    HashMap<String, String> song = new HashMap<String, String>();
    song = data.get(position);

    // Setting all values in listview
    title.setText(song.get(Home.KEY_TITLE));
    artist.setText(song.get(Home.KEY_ARTIST));
    duration.setText(song.get(Home.KEY_DURATION));
    imageLoader.DisplayImage(song.get(Home.KEY_THUMB_URL), thumb_image);
    return vi;
}

`

  • 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-10T00:48:56+00:00Added an answer on June 10, 2026 at 12:48 am

    You cannot do any UI modification.. such as setting a label text, modifying list inside a AsyncTask.doInBackground.. because it is a separate thread…

      list=(ListView)findViewById(R.id.list);
    
    
        // Getting adapter by passing xml data ArrayList
        adapter=new LazyAdapter(this, songsList);        
        list.setAdapter(adapter);
        // Click event for single list row
        list.setOnItemClickListener(new OnItemClickListener() {
    
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
    
    
            }
        });
    

    you should put that part of the code before you call

    new LoadViewTask().execute();

    and inside the doInBackground()… as the last line..
    put this line..
    adapter.notifyDataSetChanged();

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an app that will fetch updated data about the current song online,
Building an iPhone OS application that will allow users to anonymously post information to
Building a commercial product may use various open source libraries that have use of
Building an NSCharacter set to restrict a UITextField for entering user names. I want
Building a rails B2B application that will have various users. I'm pretty clear on
Building a stand alone WPF application that uses a MSSQL backend. I would like
Building an ASP.NET MVC3 application at work and I'm trying to use a program
I'm building scrobbler, and I want my program to wait 10 seconds after song
I'm building an application that has a media player in it (I'm using iOS
building a site using PHP and MySQL that needs to store a lot of

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.