android - linearLayout not included in R java file -
so following tutorial found here: developer site.
my code looks below:
import android.os.bundle; import android.app.activity; import android.widget.linearlayout; import com.google.android.gms.ads.adrequest; import com.google.android.gms.ads.adsize; import com.google.android.gms.ads.adview; // simple {@link activity} embeds adview. public class mainactivity extends activity { // view show ad. private adview adview; // ad unit id. replace actual ad unit id. private static final string ad_unit_id = "insert_your_ad_unit_id_here"; // called when activity first created. @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); // create ad. adview = new adview(this); adview.setadsize(adsize.banner); adview.setadunitid(ad_unit_id); // add adview view hierarchy. view have no size // until ad loaded. linearlayout layout = (linearlayout) findviewbyid(r.id.linearlayout); layout.addview(adview); // create ad request. check logcat output hashed device id // test ads on physical device. adrequest adrequest = new adrequest.builder() .addtestdevice(adrequest.device_id_emulator) .addtestdevice("insert_your_hashed_device_id_here") .build(); // start loading ad in background. adview.loadad(adrequest); } @override public void onresume() { super.onresume(); if (adview != null) { adview.resume(); } } @override public void onpause() { if (adview != null) { adview.pause(); } super.onpause(); } // called before activity destroyed. @override public void ondestroy() { // destroy adview. if (adview != null) { adview.destroy(); } super.ondestroy(); } }
however, getting single unresolved error keeping me testing app. on line
linearlayout layout = (linearlayout) findviewbyid(r.id.linearlayout);
i getting error linearlayout being unresolved. r , r.id fine. when r.java sure enough there no linearlayout. don't want put in there, since r.java generated.
i'm still new android development, , don't know how resolve issue. how make things included in r.java? i've tried editing files such activity_main.xml include linearlayout, when , try run app "installation error: unknown error. please check logcat more details.". don't know logcat trying tell me when @ it. have "import android.widget.linearlayout". don't know / i'm doing wrong.
you job solving problem. such as
1)may not identify id linearlayout of linearlayout 2)import linearlayout class 3)you clean project. 4)you delete bin , gen folder
Comments
Post a Comment