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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:37:44+00:00 2026-06-15T10:37:44+00:00

I use AsynTask for get data from net and show in Textview, this is

  • 0

I use AsynTask for get data from net and show in Textview, this is my code

public class PatientAssistant extends Activity {

    private TextView txtTemp,txtHuminity;


    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.patient_assistant);
        AppPreferences pref=new AppPreferences(this);

        TextView textCity=(TextView)findViewById(R.id.txtCity);

        txtTemp=(TextView)findViewById(R.id.txtTemp);
        txtHuminity=(TextView)findViewById(R.id.txtHumidity);

        textCity.setText(pref.getCity());

        String city=(String) textCity.getText();

        CallWeatherAsync cwa=new CallWeatherAsync(this,txtTemp,txtHuminity);

        cwa.execute(city);


        Button btnSend=(Button)findViewById(R.id.btnSend);
        btnSend.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                //TODO send report

            }
        });
    }

    private class CallWeatherAsync extends AsyncTask<String, Void, WeatherInfo> {

        private PatientAssistant _activity;
        private TextView txtT,txtH;
        public CallWeatherAsync(PatientAssistant activity,TextView txtTmp,TextView txthum)
        {
            _activity=activity;
            txtT=txtTmp;
            txthum=txtH;
        }
        @Override
        protected WeatherInfo doInBackground(String... params) {

            YahooWeatherUtils yahooWeatherUtils = YahooWeatherUtils.getInstance();

            WeatherInfo weatherInfo = yahooWeatherUtils.queryYahooWeather(_activity.getApplicationContext(), params[0]);
            return weatherInfo;
        }
        @Override
        protected void onPostExecute(WeatherInfo result) {

            txtT.setText(result.getCurrentTempC());
            txtH.setText(result.getAtmosphereHumidity());
        }

    }

}

but this throws Resources$NotFoundException!!!

12-02 00:39:06.383: E/AndroidRuntime(4035): android.content.res.Resources$NotFoundException: String resource ID #0xc
12-02 00:39:06.383: E/AndroidRuntime(4035):     at android.content.res.Resources.getText(Resources.java:247)
12-02 00:39:06.383: E/AndroidRuntime(4035):     at android.widget.TextView.setText(TextView.java:3473)
12-02 00:39:06.383: E/AndroidRuntime(4035):     at com.assitant.patient.PatientAssistant$CallWeatherAsync.onPostExecute(PatientAssistant.java:116)
12-02 00:39:06.383: E/AndroidRuntime(4035):     at com.assitant.patient.PatientAssistant$CallWeatherAsync.onPostExecute

How I can do this?

  • 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-15T10:37:45+00:00Added an answer on June 15, 2026 at 10:37 am

    Blind guess is that:

    txtT.setText(result.getCurrentTempC());
    txtH.setText(result.getAtmosphereHumidity());
    

    returns int not string. And if it is int then it is considered resource Id. This shall work:

    txtT.setText( "" + result.getCurrentTempC());
    txtH.setText( "" + result.getAtmosphereHumidity());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my Activity class where i use AsyncTask to get data from a
I use asynctask to get data from web services. But progessdialog not show when
i use the following code for downloading a file from the internet. using this
I have an Activity that retrieves data from a web service. This data is
In order to get XML data from a server repeatedly, I'm attempting to use
In my application I use JSON webservice to get data from Google Navigation api
I have a backgorund thread that extends AsyncTask and which I use in activity
Possible Duplicate: I need a good way to get data from a thread to
I have an android application which in its main activity, data are adapted from
I'm reading some GPS data (longitude,latitude) from a ServerManager class that stores it. The

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.