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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:01:31+00:00 2026-06-11T14:01:31+00:00

For an Android app…I have a button on an Activity that calls a custom

  • 0

For an Android app…I have a button on an Activity that calls a custom ListActivity. This ListActivity has two lines of text and a checkbox. When invoked, the ListActivity opens up an XML file on the device (local.xml) . This XML file contains a list of target XML files on the web. If the file exists on the device, the checkbox on the ListActivity is checked, otherwise it isn’t.

When the ListItem is pressed, it checks to see if the target file exists on the device-if it does, it displays a dialog box asking if they want to overwrite. If the file doesn’t exist, or if they chose to overwrite, a progress dialog is displayed as it goes to the internet and grabs a set of files (the target XML file contains a list of JPegs to gather).

After downloading the JPegs, I change the message on the progress to show whether all the JPegs downloaded or not. It sleeps for a few seconds, then disapears.

All of the above works.

My questions are:

  1. After completion, how do I set the checkbox associated with the pressed item, based on whether all of the JPegs downloaded or not?

  2. I’d really like a tri-state indicator instead of a checkbox, which is binary, unless I could change the color to yellow. Is there a better widget I should be using here?

Relvant code follows (let me know if you need to see more)

Initial Activity:

public class RRS_Preferences extends Activity {
    onCreate(yadda, yadda)  {
}

public void Button_Listener(View view)  {
    /* open up the ListView Activity */
    Intent myIntent = new Intent();
    myIntent.setClassName("com.sinisterlabs.mypackage", "com.sinisterlabs.mypackage.Download_List");
    startActivity(myIntent);
    }
}

Custom List Activity:

public class Download_List extends ListActivity {
    List<Location>loc_list = new ArrayList<Location>();

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setListAdapter(new RRSList_ArrayAdapter(this));
        selection = (TextView)findViewById(R.id.tableRow1);

        /* Open the "local.xml" file, pull from it the list of files that need to go
        onto the ListActivity. For each file, I add it to the List.  */
        loc_list.add(new Location(stringLocalFilename, stringURL, booleanIsPresent));
    }

    protected void onListItemClick(final ListView parent, final View v, int position, long href)    {
        if (fileLocalFile.exists)   {
            subDownloadJPegs(fileLocalFile);

        } else {    // Ask to download or not?
            AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
            alertBuilder.setMessage("Are you sure you want to OverWrite this file and all of its image files?")
                .setCancelable(false)
                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                        subDownloadJPegs(fileLocalFile);
                        }
                    });
                .setNegativeButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                        Toast.makeText(getApplicationContext(), "OverWrite Operation Cancelled...", Toast.LENGTH_LONG).show();
                        }
                    });
            AlertDialog alert = alertBuilder.create();
            alert.show();
        }
    }

    private void subDownloadJPegs(fileLocalFile)    {
        progDialog = new ProgressDialog(this);
        progDialog.setCancelable(true);
        progDialog.setMessage("Downloading files for " + fileLocalFile.toString() + "...");
        progDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progDialog.setProgress(0);
        /* open up this file and count the number of JPegs to be downloaded */
        progDialog.setMax(intMax);
        progDialog.setMessage("Downloading Sign Files for " + RuleSetName + "...");
        progDialog.show();

        /* background thread to update progress bar */
        Thread background = new Thread (new Runnable() {
        @Overide
        public void run() {
            /* Inside a loop, download each file, increment the progress bar as we do */
            progressHandler.sendMessage(progressHandler.obtainMessage());
        }
        background.start();
    }

    Handler progressHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            progDialog.incrementProgressBy(1);
        }
}

List Item Layout XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <CheckBox
        android:id="@+id/checkBox1"
        android:layout_width="50dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:clickable="false"
        android:focusable="false"
        android:gravity="center" />

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView android:id="@+id/text1" 
            android:layout_width="fill_parent" 
            android:layout_height="20dp" 
            android:textSize="18dp"></TextView>

        <TextView android:id="@+id/text2" 
            android:layout_width="fill_parent" 
            android:layout_height="15dp"
            android:textSize="13dp"></TextView>

    </LinearLayout>
</LinearLayout>

Thanks!!!

  • 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-11T14:01:32+00:00Added an answer on June 11, 2026 at 2:01 pm

    OK, I got it. the problem was where I placed the call to dismiss the dialog box. It ended up inside a catch statement and was never executing. In fixing this, I also parameterized my calls to the handler, which made things clearer.

    Wheh!
    🙂

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

Sidebar

Related Questions

My Android app has a button that executes this code in order to open
My Android app has a layout that looks like this: --------------------- | | |
My android app requires that the device has an SDcard and that SDcard is
My android app has a two word app name, and the 2nd word doesn't
My android-app gets List in the one activity, but activity,that contains the LisView for
My Android app has two Spinners (dropdown menus) working fine. However, now I've added
My Android app has a tab bar that uses an Intent to launch the
My android app works on landscape mode. I have a listview that contains some
My android app is keep giving me this error. The application has stopped working
My Android app has a WebView that requires the Flash plugin. The webview will

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.