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; }
}
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;
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.