java - Stuck on WebView Tutorial - R.id issue? -
good morning - hope has had enjoyable weekend.
i having issues following tutorial @ https://developer.chrome.com/multidevice/webview/gettingstarted
everything going until reach step regarding edit of mainactivity class. step 3 in section add webview: https://developer.chrome.com/multidevice/webview/gettingstarted#add_the_webview
here content of androidmanifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.nathan.myapplication" > <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".myactivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.internet" /> </manifest>
and here myactivity.java:
package com.example.nathan.myapplication; import android.app.activity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.webkit.webview; public class myactivity extends activity { private webview mwebview; // added nd guthrie 8.15.2014:2229 @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_my); mwebview = (webview)findviewbyid(r.id.activity_my_webview); // added nd guthrie 8.15.2014:2231 } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.my, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); } }
i have tried suggestions based on these links here on stackoverflow:
error r class import in android
android studio don't generate r.java import project
for error r class import, have attempted adding line
import com.testapp.hellowebview.r;
but no success, testapp not recognized. stands reason, since have not named 'testapp' in app here, not understand how fix it.
i tried deleting generated folder , cleaning , rebuilding project. however, obtain same results.
i know silly little thing, have been searching google , stackoverflow days now, , seems there not seeing.
any ideas? please advise.
thank time!
best, nathan
the way works xml files compiled resources in background eclipse, , r.java gets generated allows project refer these resources. if put "r.id.blah" or "r.layout.blah" or whatever eclipse , isn't recognised, means 1 of following:
- your xml files don't have corresponding elements. r.java being created, doesn't contain "r.id.blah" or whatever you're using, because xml files don't contain elements compile ids.
- r.java couldn't compiled @ all. that'll case if there errors in project. you're best off making sure there no errors (no red crosses anywhere), , seeing whether r.java appears. once you've done that, you'll able find out ids being generated, , should point in direction of what's missing or inconsistent in xml files.
Comments
Post a Comment