How do I make a variable global across a Java file -


in lua global variablename , bam global there simple way in java?

here code, want loc variable global public view getview(int position, view convertview, viewgroup parent){ can use it:

class custom_row_adapter extends arrayadapter<integer> {       custom_row_adapter(context context, int picid, string url) {         super(context, r.layout.activity_custom_row_adapter, picid);         string loc = url; } @override public view getview(int position, view convertview, viewgroup parent){         layoutinflater picinflater = layoutinflater.from(getcontext());         view customview = picinflater.inflate(r.layout.activity_custom_row_adapter, parent, false);         string singlepic = getitem(loc + string.valueof(position) + ".jpg"); **//this loc viewed**         imageview theimage = (imageview) customview.findviewbyid(r.id.singleimg);         glide.with(this).load(singlepic).into(theimage);         return customview; } 

}

just add , field this

public class example {  private string loc;  class custom_row_adapter extends arrayadapter<integer> {     custom_row_adapter(context context, int picid, string url) {         super(context, r.layout.activity_custom_row_adapter, picid);         loc = url;     }   } } 

Comments