Android,数组到for循环

Android,数组到for循环,android,arrays,for-loop,Android,Arrays,For Loop,我有一个数组,如下所示,我手动写下照片链接,我有一个问题,如何将数组转换为for循环,以便在我更改SQL中的链接后图像将自动更新 public View getView(int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(mContext); i.setImageResource(mImageIds[position]);

我有一个数组,如下所示,我手动写下照片链接,我有一个问题,如何将数组转换为for循环,以便在我更改SQL中的链接后图像将自动更新

public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(mContext);

            i.setImageResource(mImageIds[position]);                             

            return i;
        }        

        private Integer[] mImageIds = {
                R.drawable.ctr,
                R.drawable.fb,
                R.drawable.games,
                R.drawable.ic_launcher,
                R.drawable.ctr,
                R.drawable.ctr,
                R.drawable.ctr,
                R.drawable.ctr,
                R.drawable.ea,
                R.drawable.fb,
                R.drawable.ctr
        };

更新 我想我几乎解决了这个问题: 我把它们放在getView()下

public View getView(int位置、视图转换视图、视图组父视图){
ImageView i=新的ImageView(mContext);
最后一个字符串SOAP_ACTION=”http://tempuri.org/findAppsByID";
最终字符串方法\u NAME=“findAppsByID”;
最终字符串名称空间=”http://tempuri.org/";
最终字符串URL=”http://domainURL.com/appsFeaturedWS.asmx";
SoapObject请求=新的SoapObject(名称空间、方法名称);
请求。添加属性(“ID”,位置+1);
SoapSerializationEnvelope soapEnvelope=新的SoapSerializationEnvelope(soapEnvelope.VER11);
soapEnvelope.dotNet=true;
setOutputSoapObject(请求);
AndroidHttpTransport aht=新的AndroidHttpTransport(URL);
尝试
{
aht.call(SOAP\u动作,soapEnvelope);
SoapObject resultString=(SoapObject)soapEnvelope.getResponse();
最终字符串[]strLogo=新字符串[resultString.getPropertyCount()];

对于(int j=0;jmimageid定义全局

public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(mContext);
            for(int i=0;i<mImageIds.length;i++{
            if(i==position){ 
             i.setImageResource(mImageIds[position]);                             
             }
            }
            return i;
        }        

        private Integer[] mImageIds = {
                R.drawable.ctr,
                R.drawable.fb,
                R.drawable.games,
                R.drawable.ic_launcher,
                R.drawable.ctr,
                R.drawable.ctr,
                R.drawable.ctr,
                R.drawable.ctr,
                R.drawable.ea,
                R.drawable.fb,
                R.drawable.ctr
        };
public View getView(int位置、视图转换视图、视图组父视图){
ImageView i=新的ImageView(mContext);

例如(int i=0;i检查LazyAdapter示例的链接,该示例有助于从网络中获取图像,以便在gridview、listview或gallary视图中显示检查它

我想你不明白我的问题:)让你存储整数i的值,其中int i=R.drawable.image1,或者如果你试图从网络上显示图像,则此值不可用bcz apk为只读以显示网络图像,而你必须使用惰性适配器,因为没有apk,存在图像。我将图像url存储在服务器上。我想知道我的代码显示图像是否正确?特别是第i.setImageResource行(Integer.parseInt(strLogo[j]);无论如何,我找不到任何带有数组+图像url的示例,它们都使用R.drawable。忘记所有这些复杂性,我只是尝试从网络获取url也无法。这就是我使用的,请建议我。应用程序甚至不显示图像,我更改了i.setImageResource(mimageId)[position]);到i.setImageURI(Uri.parse(“);返回i;如果你没有任何想法,就来讨论
public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(mContext);
            for(int i=0;i<mImageIds.length;i++{
            if(i==position){ 
             i.setImageResource(mImageIds[position]);                             
             }
            }
            return i;
        }        

        private Integer[] mImageIds = {
                R.drawable.ctr,
                R.drawable.fb,
                R.drawable.games,
                R.drawable.ic_launcher,
                R.drawable.ctr,
                R.drawable.ctr,
                R.drawable.ctr,
                R.drawable.ctr,
                R.drawable.ea,
                R.drawable.fb,
                R.drawable.ctr
        };