Cannot result R.string.page_title, R.string.page_title, R.layout.main etc












-1














I am new to Java and Android development. I am using Android Studio and learning how to parse XML data from this guide: https://developer.android.com/training/basics/network-ops/xml#analyze



I created a new class Network Activity and put all the code from the guide there.



The code from the website uses:




  • R.string.page_title

  • R.string.page_title

  • R.string.connection_error

  • R.string.xml_error

  • R.layout.main

  • R.id.webview


Every single one of them throws cannot find symbol variable X error.



I tried:




  1. Closing and opening Android Studio and/or cleaning and rebuilding

  2. I added Network Activity to AndroidManifext.xml

  3. I made sure I don't import android.R.


I followed every solution I could find online and I still have this problem.










share|improve this question


















  • 1




    have you declared those strings in strings.xml?
    – Touhidul Islam
    Nov 20 '18 at 13:54


















-1














I am new to Java and Android development. I am using Android Studio and learning how to parse XML data from this guide: https://developer.android.com/training/basics/network-ops/xml#analyze



I created a new class Network Activity and put all the code from the guide there.



The code from the website uses:




  • R.string.page_title

  • R.string.page_title

  • R.string.connection_error

  • R.string.xml_error

  • R.layout.main

  • R.id.webview


Every single one of them throws cannot find symbol variable X error.



I tried:




  1. Closing and opening Android Studio and/or cleaning and rebuilding

  2. I added Network Activity to AndroidManifext.xml

  3. I made sure I don't import android.R.


I followed every solution I could find online and I still have this problem.










share|improve this question


















  • 1




    have you declared those strings in strings.xml?
    – Touhidul Islam
    Nov 20 '18 at 13:54
















-1












-1








-1







I am new to Java and Android development. I am using Android Studio and learning how to parse XML data from this guide: https://developer.android.com/training/basics/network-ops/xml#analyze



I created a new class Network Activity and put all the code from the guide there.



The code from the website uses:




  • R.string.page_title

  • R.string.page_title

  • R.string.connection_error

  • R.string.xml_error

  • R.layout.main

  • R.id.webview


Every single one of them throws cannot find symbol variable X error.



I tried:




  1. Closing and opening Android Studio and/or cleaning and rebuilding

  2. I added Network Activity to AndroidManifext.xml

  3. I made sure I don't import android.R.


I followed every solution I could find online and I still have this problem.










share|improve this question













I am new to Java and Android development. I am using Android Studio and learning how to parse XML data from this guide: https://developer.android.com/training/basics/network-ops/xml#analyze



I created a new class Network Activity and put all the code from the guide there.



The code from the website uses:




  • R.string.page_title

  • R.string.page_title

  • R.string.connection_error

  • R.string.xml_error

  • R.layout.main

  • R.id.webview


Every single one of them throws cannot find symbol variable X error.



I tried:




  1. Closing and opening Android Studio and/or cleaning and rebuilding

  2. I added Network Activity to AndroidManifext.xml

  3. I made sure I don't import android.R.


I followed every solution I could find online and I still have this problem.







android






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 13:48









Adrian WydmanskiAdrian Wydmanski

737414




737414








  • 1




    have you declared those strings in strings.xml?
    – Touhidul Islam
    Nov 20 '18 at 13:54
















  • 1




    have you declared those strings in strings.xml?
    – Touhidul Islam
    Nov 20 '18 at 13:54










1




1




have you declared those strings in strings.xml?
– Touhidul Islam
Nov 20 '18 at 13:54






have you declared those strings in strings.xml?
– Touhidul Islam
Nov 20 '18 at 13:54














1 Answer
1






active

oldest

votes


















2














The sample code from this guide uses these strings, for example when returning an error :



@Override
protected String doInBackground(String... urls) {
try {
return loadXmlFromNetwork(urls[0]);
} catch (IOException e) {
return getResources().getString(R.string.connection_error);
} catch (XmlPullParserException e) {
return getResources().getString(R.string.xml_error);
}
}


You need to add these values to your strings.xml file. It should be located under res/values/strings.xml and will look like this after you add the necessary values :



<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">YourApp</string>
<string name="page_title">A title</string>
<string name="connection_error">Error text</string>
...
</resources>





share|improve this answer























  • Well... I guess I skipped a few lessons. What about R.layout and R.id, where should they be placed?
    – Adrian Wydmanski
    Nov 20 '18 at 13:59












  • Your main layout file should be located under res/layout/main.xml. This file must contain a WebView widget with the id webview.
    – ArcDexx
    Nov 20 '18 at 14:01













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53394468%2fcannot-result-r-string-page-title-r-string-page-title-r-layout-main-etc%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














The sample code from this guide uses these strings, for example when returning an error :



@Override
protected String doInBackground(String... urls) {
try {
return loadXmlFromNetwork(urls[0]);
} catch (IOException e) {
return getResources().getString(R.string.connection_error);
} catch (XmlPullParserException e) {
return getResources().getString(R.string.xml_error);
}
}


You need to add these values to your strings.xml file. It should be located under res/values/strings.xml and will look like this after you add the necessary values :



<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">YourApp</string>
<string name="page_title">A title</string>
<string name="connection_error">Error text</string>
...
</resources>





share|improve this answer























  • Well... I guess I skipped a few lessons. What about R.layout and R.id, where should they be placed?
    – Adrian Wydmanski
    Nov 20 '18 at 13:59












  • Your main layout file should be located under res/layout/main.xml. This file must contain a WebView widget with the id webview.
    – ArcDexx
    Nov 20 '18 at 14:01


















2














The sample code from this guide uses these strings, for example when returning an error :



@Override
protected String doInBackground(String... urls) {
try {
return loadXmlFromNetwork(urls[0]);
} catch (IOException e) {
return getResources().getString(R.string.connection_error);
} catch (XmlPullParserException e) {
return getResources().getString(R.string.xml_error);
}
}


You need to add these values to your strings.xml file. It should be located under res/values/strings.xml and will look like this after you add the necessary values :



<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">YourApp</string>
<string name="page_title">A title</string>
<string name="connection_error">Error text</string>
...
</resources>





share|improve this answer























  • Well... I guess I skipped a few lessons. What about R.layout and R.id, where should they be placed?
    – Adrian Wydmanski
    Nov 20 '18 at 13:59












  • Your main layout file should be located under res/layout/main.xml. This file must contain a WebView widget with the id webview.
    – ArcDexx
    Nov 20 '18 at 14:01
















2












2








2






The sample code from this guide uses these strings, for example when returning an error :



@Override
protected String doInBackground(String... urls) {
try {
return loadXmlFromNetwork(urls[0]);
} catch (IOException e) {
return getResources().getString(R.string.connection_error);
} catch (XmlPullParserException e) {
return getResources().getString(R.string.xml_error);
}
}


You need to add these values to your strings.xml file. It should be located under res/values/strings.xml and will look like this after you add the necessary values :



<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">YourApp</string>
<string name="page_title">A title</string>
<string name="connection_error">Error text</string>
...
</resources>





share|improve this answer














The sample code from this guide uses these strings, for example when returning an error :



@Override
protected String doInBackground(String... urls) {
try {
return loadXmlFromNetwork(urls[0]);
} catch (IOException e) {
return getResources().getString(R.string.connection_error);
} catch (XmlPullParserException e) {
return getResources().getString(R.string.xml_error);
}
}


You need to add these values to your strings.xml file. It should be located under res/values/strings.xml and will look like this after you add the necessary values :



<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">YourApp</string>
<string name="page_title">A title</string>
<string name="connection_error">Error text</string>
...
</resources>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 20 '18 at 13:59

























answered Nov 20 '18 at 13:58









ArcDexxArcDexx

1007




1007












  • Well... I guess I skipped a few lessons. What about R.layout and R.id, where should they be placed?
    – Adrian Wydmanski
    Nov 20 '18 at 13:59












  • Your main layout file should be located under res/layout/main.xml. This file must contain a WebView widget with the id webview.
    – ArcDexx
    Nov 20 '18 at 14:01




















  • Well... I guess I skipped a few lessons. What about R.layout and R.id, where should they be placed?
    – Adrian Wydmanski
    Nov 20 '18 at 13:59












  • Your main layout file should be located under res/layout/main.xml. This file must contain a WebView widget with the id webview.
    – ArcDexx
    Nov 20 '18 at 14:01


















Well... I guess I skipped a few lessons. What about R.layout and R.id, where should they be placed?
– Adrian Wydmanski
Nov 20 '18 at 13:59






Well... I guess I skipped a few lessons. What about R.layout and R.id, where should they be placed?
– Adrian Wydmanski
Nov 20 '18 at 13:59














Your main layout file should be located under res/layout/main.xml. This file must contain a WebView widget with the id webview.
– ArcDexx
Nov 20 '18 at 14:01






Your main layout file should be located under res/layout/main.xml. This file must contain a WebView widget with the id webview.
– ArcDexx
Nov 20 '18 at 14:01




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53394468%2fcannot-result-r-string-page-title-r-string-page-title-r-layout-main-etc%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

Origin of the phrase “under your belt”?