I'm new to Java, Android etc. I have a problem that I am not able to figure out.
I have GridView
that is populated by an ImageAdapter
based on UniversalImageLoader
.
When I click a button to launch method,
public void buttonsearch(View view)
{
imagesearch();
}
GridView
normally display images.
But when I call it directly.
imagesearch("somestring");
It's showing nothing at all. By my "debug" messages I can see that ImageAdapter
is working. And when I click the button, the GridView
starts filling by content.
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);
}
});
Edit: Ok problem solved explaining will be later