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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:04:07+00:00 2026-05-28T06:04:07+00:00

I have the next code ProgressDialog pd; LinearLayout layout; ListView listview; TextView name[]; TextView

  • 0

I have the next code

     ProgressDialog pd;
 LinearLayout layout;
 ListView listview;
 TextView name[];
 TextView website[];
/** Called when the activity is first created. 
 */

@Override
public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main); 
       pd = ProgressDialog.show(this,
               "Title",
               "Message",
               true, false);

       new Thread(new Runnable(){
           public void run(){
           begin();
           pd.dismiss();
           }
           }).start();







    }




public void begin(){       
    Calendar c = Calendar.getInstance(); 

    String dia2,mes2;
    mes2="0";
   int dia = c.get(Calendar.DAY_OF_MONTH); 
   int mes = c.get(Calendar.MONTH); 




    try {

    URL url = new URL(
    "http://www.tudiscovery.com/dni-tvlistings/GetScheduleByBroadcastDate?type=day&country_code=LTM&channel_code=DCLA-SP&date="+ dia2 +""+ mes2 +"2012");



    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(new InputSource(url.openStream()));

    doc.getDocumentElement().normalize();

    NodeList nodeList = doc.getElementsByTagName("programme");

    /** Assign textview array lenght by arraylist size */
    name = new TextView[nodeList.getLength()];
    website = new TextView[nodeList.getLength()];


    for (int i = 0; i <= nodeList.getLength(); i++) {

    Node node = nodeList.item(i);

    name[i] = new TextView(this);
    website[i] = new TextView(this);


    Element fstElmnt = (Element) node;
    NodeList nameList = fstElmnt.getElementsByTagName("series-title");
    Element nameElement = (Element) nameList.item(0);
    nameList = nameElement.getChildNodes();

    name[i].setText("Programa = "
    + ((Node) nameList.item(0)).getNodeValue());

    NodeList websiteList = fstElmnt.getElementsByTagName("raw");
    Element websiteElement = (Element) websiteList.item(0);
    websiteList = websiteElement.getChildNodes();
    website[i].setText("Hora = "
    + ((Node) websiteList.item(0)).getNodeValue().subSequence(0, 2) +":" + ((Node) websiteList.item(0)).getNodeValue().subSequence(2, 4));


    name[i].setTextColor(Color.RED);
    name[i].setTextSize(12);
   layout.addView(name[i]);
    layout.addView(website[i]);



    } 


    } catch (Exception e) {
    System.out.println("XML Pasing Excpetion = " + e);
    }

when i want to get the View I got this error: Only the original thread that created a view hierarchy can touch its views.

anybody have a solution for this code?

PSD: this is a rss parse

  • 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-28T06:04:07+00:00Added an answer on May 28, 2026 at 6:04 am

    You cant update the UI on the a seperate thread. You only can update it on the Main thread

     new Thread(new Runnable(){
           public void run(){
           begin();
           pd.dismiss();
           }
           }).start();
    

    For this you should use an AsnycTask. It has methods that allow you to update the main UI while doing background work, or after or before it is complete.

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

Sidebar

Related Questions

I have a fairly simple block of code. Sub Run(Name) on error resume next
I have next code in my website. This code is an c# activex, the
I have the next code where I defined a WPF toolkit datagrid control called
I have Rails application (Redmine) and I have created next working code which close
I have the next code of view: @{ Layout = null; } @Html.Raw(ViewBag.ReportHeader as
I have the next code: document.myForm.mySubmit.click(); Where myForm - form name, mySubmit - submit
I have the next code in javascript. I deleted some unnecessary items because it
I have the next code: Process p = Runtime.getRuntime().exec(args); and I want my program
I have the following code: if ($_POST['submit'] == Next) { foreach($_POST['info'] as $key =>
myRs=myStmt.executeQuery(select i_col,col_name from tab_col) i=0 while (myRs.next()): list= myRs.getString(I_COL)+','+myRs.getString(COL_NAME) i have a jython code

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.