Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I change the images in a listvue, after it is created?
    primarykey
    data
    text
    <p>I have created a program that reads in a file from a server to construct a list view. It then loads an image in the background. Now the image is loaded into an imageview to make sure it works. How can I load the images into my listview imageview rows? </p> <pre><code>public class Welcome extends ListActivity { /** Called when the activity is first created. */ // data to load from html file ArrayList&lt;String&gt; images; ArrayList&lt;String&gt; Links; ArrayList&lt;String&gt; LinkName; ArrayList&lt;String&gt; Price; int y; ArrayList&lt;String&gt; ted; int i; String[] items={"CASUAL","DRESSES","CAREER","OUTWEAR","FOOTWEAR", "JEWELRY","ACCESSORIES"}; private HttpClient client; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // data read in can be from 1-10 images=new ArrayList(); Links=new ArrayList(); LinkName=new ArrayList(); Price=new ArrayList(); // load in arrays from a file on a web server Loaddata(); // create a listvue based on the data loaded from the server setListAdapter(new IconicAdapter(this)); // load in biytmap download(); } // end function class IconicAdapter extends ArrayAdapter { Activity context; IconicAdapter(Activity context) { super(context, R.layout.row, LinkName); this.context=context; } public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater=context.getLayoutInflater(); View row=inflater.inflate(R.layout.row, null); TextView label=(TextView)row.findViewById(R.id.label); label.setText( LinkName.get(position) ); return(row); } } private void download(){ new AsyncTask&lt;Void, Void, Bitmap&gt;(){ @Override protected Bitmap doInBackground(Void... params) { HttpClient client = new DefaultHttpClient(); try { String uri = "http://www.besttechsolutions.biz/icon.png"; HttpGet request = new HttpGet(uri); HttpResponse response = client.execute(request); return BitmapFactory.decodeStream(response.getEntity().getContent()); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Bitmap image) { if(image == null){ Log.d("ted", "could not download image"); // Toast.makeText(Main.this, "Download failed", Toast.LENGTH_LONG).show(); } else{ // losd into ListView // ImageView myimage = (ImageView) findViewById(R.id.myimage); // myimage.setImageBitmap(image); } } }.execute(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload