Note that there are some explanatory texts on larger screens.

plurals
  1. POi am trying to fetch the id of the image to display it in full view
    primarykey
    data
    text
    <p>Below is the class where i am not able to get the resource of the image id. I am trying to fetch all the data from the web service. Here i have posted all the classes from where the images are fetched.I have all the images showing it in the gridView. I am not facing problem in that, however when I click on the image of the gridview it shows me the just the xml file which I have called. I guess I am doing wrong somewhere calling the id here in the FullImageAcitivity file.</p> <p>DefaultGridView.java</p> <pre><code> public class DefaultGridView extends Activity { //int position; public void onBackPressed() { // TODO Auto-generated method stub super.onBackPressed(); finish(); } GridView gridView; Context context=this; DisplayImageOptions options; protected ImageLoader imageLoader = ImageLoader.getInstance(); @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.latestphotos); gridView=(GridView)findViewById(R.id.grid_view); options = new DisplayImageOptions.Builder() .showStubImage(R.drawable.stub_image) .showImageForEmptyUri(R.drawable.image_for_empty_url) .cacheInMemory() .cacheOnDisc() .bitmapConfig(Bitmap.Config.RGB_565) .build(); gridView.setAdapter(new ImageAdapter()); } public class ImageAdapter extends BaseAdapter { LayoutInflater inflater = LayoutInflater.from(context); public ImageAdapter() { // TODO Auto-generated constructor stub imageLoader.init(ImageLoaderConfiguration.createDefault(DefaultGridView.this)); } @Override public int getCount() { return Global.getPhotos_list().size(); } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View view, ViewGroup viewGroup) { View v = view; ImageView picture; TextView name; if(v == null) { v = inflater.inflate(R.layout.other, viewGroup, false); v.setTag(R.id.picture, v.findViewById(R.id.picture)); v.setTag(R.id.text, v.findViewById(R.id.text)); } picture = (ImageView)v.getTag(R.id.picture); name = (TextView)v.getTag(R.id.text); Item item = (Item)items.get(i); picture.setImageResource(item.getDrawable()); name.setText(item.name); Log.d("position", position+""); imageLoader.displayImage(Constant.img_URL+Global.getPhotos_list().get(position).get("photo_name"), picture , options,null,context); gridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long a) { Intent i = new Intent(getApplicationContext(), FullImageActivity.class); i.putExtra("idkey", position); // pass the id startActivity(i); } }); return v; } } } </code></pre> <p>FullImageActivity.java</p> <pre><code>public class FullImageActivity extends Activity { Button download, setas; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.full_image); setas = (Button) findViewById(R.id.setas); download = (Button)findViewById(R.id.download); // get intent data final Intent i = getIntent(); // Selected image id ImageView imageView = (ImageView) findViewById(R.id.full_image_view); int id = getIntent().getIntExtra("idkey",-1); //get id imageView.setImageResource(id); setas.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub WallpaperManager myWallpaperManager = WallpaperManager.getInstance(getApplicationContext()); try { myWallpaperManager.setResource(R.id.full_image_view); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } } </code></pre> <p>ImageAdapter.java</p> <pre><code>public class ImageAdapter extends BaseAdapter { private LayoutInflater inflater; List&lt;Item&gt; items; public ImageAdapter(Context context,List&lt;Item&gt; items) { inflater = LayoutInflater.from(context); this.items = items; } @Override public int getCount() { return items.size(); } @Override public Object getItem(int i) { return items.get(i); } @Override public long getItemId(int i) { return items.get(i).drawable; } @Override public View getView(int i, View view, ViewGroup viewGroup) { View v = view; ImageView picture; TextView name; if(v == null) { v = inflater.inflate(R.layout.other, viewGroup, false); v.setTag(R.id.picture, v.findViewById(R.id.picture)); v.setTag(R.id.text, v.findViewById(R.id.text)); } picture = (ImageView)v.getTag(R.id.picture); name = (TextView)v.getTag(R.id.text); Item item = (Item)items.get(i); picture.setImageResource(item.getDrawable()); name.setText(item.name); return v; } } </code></pre> <p>Items.java</p> <pre><code>public class Item { String name; int drawable; public int getDrawable() { return drawable; } public void setDrawable(int drawable) { this.drawable = drawable; } public Item(String name, int id) { this.name= name; this.drawable = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } </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.
 

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