我是 Java、Android 等的新手。我有一个我无法弄清楚的问题。
我有GridView
一个ImageAdapter
基于UniversalImageLoader
. 当我单击按钮启动方法时,
public void buttonsearch(View view)
{
imagesearch();
}
GridView
正常显示图像。但是当我直接调用它时。
imagesearch("somestring");
它根本什么都没有显示。通过我的“调试”消息,我可以看到它ImageAdapter
正在工作。当我单击按钮时,GridView
开始按内容填充。
private void imagesearch(String... params) throws ClientProtocolException,
JSONException, IOException, InterruptedException,
ExecutionException {
EditText wordimage = (EditText) findViewById(R.id.wordimage);
String previos = null;
String wordtotr = null;
String strwordtos = null;
if ( params.length != 0 )
{
previos = params[0];
}
if ( previos != null)
{
strwordtos = previos;
wordimage.setText(strwordtos);
}
strwordtos = wordimage.getText().toString().replaceAll(" ", "%20");
parsejsonimages getUrls = new parsejsonimages();
getUrls.execute(strwordtos);
urlsp = getUrls.get();
List<String> urls = new ArrayList<String>();
urls = new ArrayList<String>(urlsp.values());
directurls = new ArrayList<String>(urlsp.keySet());
int j = 0;
while (urls.size() > j) {
urls.set(j, "http://someaddress:" + urls.get(j));
j++;
}
GridView gridview = (GridView) findViewById(R.id.gridViewImages);
Integer gwight = gridview.getWidth();
Integer ghight = gridview.getHeight();
ImageAdapter images = new ImageAdapter(this, urls, ghight, gwight);
gridview.setAdapter(images);
gridview.setSelected(true);
gridview.setOnItemClickListener(new OnItemClickListener() {
public void setalphatoimagebypos(Integer pos, Integer Alpha)
{
GridView gridview = (GridView) findViewById(R.id.gridViewImages);
ImageView imgrecoil = (ImageView) (gridview
.getChildAt(pos));
imgrecoil.setAlpha(Alpha);
}
public void onItemClick(AdapterView parent, View v, int position,
long id) {
if (strimgtag > -1) {
setalphatoimagebypos(strimgtag, 255);
strimgtag = position;
setalphatoimagebypos(strimgtag, 128);
}
});
编辑:好的问题已解决,稍后解释