Reputation: 640
In lua I could just do global variablename
and bam its global
is there a simple way to do this in java?
Here is my code, I want the loc
variable to be global so the 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 is where loc is viewed** ImageView theImage = (ImageView) customView.findViewById(R.id.singleImg); Glide.with(this).load(singlePic).into(theImage); return customView; }
}
Upvotes: 1
Views: 58
Reputation: 132
just add it as and field like 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;
}
}
}
Upvotes: 2