Java 在array android应用程序中传递arraylist
我一直在使用此应用程序制作图库模块Java 在array android应用程序中传递arraylist,java,android,json,parsing,arrays,Java,Android,Json,Parsing,Arrays,我一直在使用此应用程序制作图库模块 但是,根据我的应用程序中的要求,图像是动态添加的。因此,我通过JSON获取所有图像。JSON Iam的图像响应添加到arraylist中 如何在新类中传递“image\u url.add(folio.getString(I));”: public class Test extends Activity{ private static String url = "http://www.xyz.com/album_pro/array_to_encode
但是,根据我的应用程序中的要求,图像是动态添加的。因此,我通过JSON获取所有图像。JSON Iam的图像响应添加到arraylist中 如何在新类中传递“
image\u url.add(folio.getString(I));
”:
public class Test extends Activity{
private static String url = "http://www.xyz.com/album_pro/array_to_encode";
JSONArray folio = null;
ArrayList<String> urlList = new ArrayList<String>();
@SuppressLint("NewApi")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
JSONParser jParser = new JSONParser();
{
try{
JSONObject json = jParser.getJSONFromUrl(url);
Log.v("URL",json.toString());
JSONObject seo = json.getJSONObject("SEO");
Log.v("seo",seo.toString());
JSONArray folio = seo.getJSONArray("Folio");
ArrayList<String> image_urls = new ArrayList<String>();
for(int i=0;i< folio.length();i++)
{
image_urls.add(folio.getString(i));
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
将
ArrayList
public
和static
作为测试在其他类中使用。urlList
简单的方法是将图像URL
作为public static。因为它只包含URL,对吗?只有少量的数据和图像类中的数据可以访问
Test.image_urls.get(integer);
将
图像
成员设为非最终成员,以便在运行时对其进行设置
在将图像URL添加到image\u URL
ArrayList的循环之后,设置Images
类的属性:
Images.imageUrls = image_urls.toArray();
问题是什么?@NikitaBeloglazov:我应该如何在新的类I中传递“image_url.add(folio.getString(I));”。e@Shweta新班级在哪里?如果新类是一个非活动类@ρцσѕρєK,则使用类构造函数:它是一个非活动类class@Shweta使用ArrayList而不是Array…并获取create方法以向ArrayList添加元素
Images.imageUrls = image_urls.toArray();