我有一个数组,如下所示,我手动记下照片链接,我有一个问题如何将数组转换为 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 position, View convertView, ViewGroup parent) {
ImageView i = new ImageView(mContext);
final String SOAP_ACTION = "http://tempuri.org/findAppsByID";
final String METHOD_NAME = "findAppsByID";
final String NAMESPACE = "http://tempuri.org/";
final String URL = "http://domainURL.com/appsFeaturedWS.asmx";
SoapObject Request = new SoapObject (NAMESPACE, METHOD_NAME);
Request.addProperty("ID", position+1);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
AndroidHttpTransport aht = new AndroidHttpTransport(URL);
try
{
aht.call(SOAP_ACTION, soapEnvelope);
SoapObject resultString = (SoapObject) soapEnvelope.getResponse();
final String[] strLogo = new String[resultString.getPropertyCount()];
for(int j =0; j<resultString.getPropertyCount(); j++)
{
SoapObject array = (SoapObject) resultString .getProperty(j);
strLogo[j] = array.getProperty(5).toString(); //get logo
i.setImageResource(Integer.parseInt(strLogo[j]));
}
}
catch(Exception e){
}
return i;
}
但我的屏幕只是显示空白......有什么问题吗?