android - How to know what 'this' keyword refers to when reading any codes? -
i'm learning android. i've known this keyword when creating constructor. however, still confusing me know this refers in other situations.
specifically, when reading code examples, in methods, passed in this parameter, , dont know this means cannot replicate code later uses.
please intruct me should find out reference 'this' when reading code or giving parameter 'this'.
thank much!
see example:
public class example_5 extends appcompatactivity { listview lv5; list<country> countries; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_example_5); lv5 = (listview) findviewbyid(r.id.lv5); countries = new arraylist<>(); countries.add(new country("vietnam", "việt nam", r.drawable.flag_vi)); countries.add(new country("laos", "lào", r.drawable.flag_fr)); countries.add(new country("japan", "nhật bản", r.drawable.flag_jp)); countries.add(new country("usa", "mỹ", r.drawable.flag_us)); countryadapter3 adapter3 = new countryadapter3(this, countries, r.layout.item_layout_3); lv5.setadapter(adapter3); } }
do this:
toast.maketext(this, this.getclass().tostring(), toast.length_short).show();
you see class name
Comments
Post a Comment