Cannot result R.string.page_title, R.string.page_title, R.layout.main etc
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:
- Closing and opening Android Studio and/or cleaning and rebuilding
- I added
Network Activity
toAndroidManifext.xml
- I made sure I don't
import android.R
.
I followed every solution I could find online and I still have this problem.
android
add a comment |
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:
- Closing and opening Android Studio and/or cleaning and rebuilding
- I added
Network Activity
toAndroidManifext.xml
- I made sure I don't
import android.R
.
I followed every solution I could find online and I still have this problem.
android
1
have you declared those strings in strings.xml?
– Touhidul Islam
Nov 20 '18 at 13:54
add a comment |
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:
- Closing and opening Android Studio and/or cleaning and rebuilding
- I added
Network Activity
toAndroidManifext.xml
- I made sure I don't
import android.R
.
I followed every solution I could find online and I still have this problem.
android
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:
- Closing and opening Android Studio and/or cleaning and rebuilding
- I added
Network Activity
toAndroidManifext.xml
- I made sure I don't
import android.R
.
I followed every solution I could find online and I still have this problem.
android
android
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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>
Well... I guess I skipped a few lessons. What aboutR.layout
andR.id
, where should they be placed?
– Adrian Wydmanski
Nov 20 '18 at 13:59
Your main layout file should be located underres/layout/main.xml
. This file must contain aWebView
widget with the idwebview
.
– ArcDexx
Nov 20 '18 at 14:01
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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>
Well... I guess I skipped a few lessons. What aboutR.layout
andR.id
, where should they be placed?
– Adrian Wydmanski
Nov 20 '18 at 13:59
Your main layout file should be located underres/layout/main.xml
. This file must contain aWebView
widget with the idwebview
.
– ArcDexx
Nov 20 '18 at 14:01
add a comment |
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>
Well... I guess I skipped a few lessons. What aboutR.layout
andR.id
, where should they be placed?
– Adrian Wydmanski
Nov 20 '18 at 13:59
Your main layout file should be located underres/layout/main.xml
. This file must contain aWebView
widget with the idwebview
.
– ArcDexx
Nov 20 '18 at 14:01
add a comment |
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>
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>
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 aboutR.layout
andR.id
, where should they be placed?
– Adrian Wydmanski
Nov 20 '18 at 13:59
Your main layout file should be located underres/layout/main.xml
. This file must contain aWebView
widget with the idwebview
.
– ArcDexx
Nov 20 '18 at 14:01
add a comment |
Well... I guess I skipped a few lessons. What aboutR.layout
andR.id
, where should they be placed?
– Adrian Wydmanski
Nov 20 '18 at 13:59
Your main layout file should be located underres/layout/main.xml
. This file must contain aWebView
widget with the idwebview
.
– 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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
have you declared those strings in strings.xml?
– Touhidul Islam
Nov 20 '18 at 13:54